Trying to give users the option of which field to sort on

Hey everyone! Right now my Query All Records function is sorting on Date Desc by default. And so our users will always see records from recent to old.

However, I'd like to give them the option to choose which field to sort on, eg either Date or Price or X or Y (I have several other fields to sort on).

From what I've seen, it looks like the only way to do this would be to:

  1. Create an input to identify sort field, InputSort, which can be any of (Date, Price, X, Y)

  2. Create an IF THEN logic in the function that forks based on the sort variable, eg IF InputSort = Date THEN QuerySortByDate function, IF InputSort = Price THEN QuerySortByPrice function, etc

  3. However, this requires copying the base Query All Records function and adjust the hardcoded Output Sort configuration for each of the possible sort forks. This feels a bit cumbersome - if I have to make changes to the query, I have to make changes to each of the queries for each sort fork.

Is there a more efficient way to handle this?

Thanks!

3 replies