Server side sort using codeless and event handler

Hi,
I am trying to add the sortBy parameter into a query in a beforeFind event handler as mentioned here:

See the example attached. (i have tried to add the order by clause with text, raw text,
as ‘name asc’ and as ‘order by name asc’.
The code is deployed but i do not see any change in how the records are returned (using REST Console and a data table in the UI builder).
I have also tried to return the Request Query block in the API Event before find block, but that’s not it.

Obviously I am using the wrong syntax or property name.
Thanks for any hints you can provide.

Best regards, Thomas

Hi Thomas,

Yes, this is not very straight-forward, we should do a better job documenting the request structure. Here’s the codeless logic that will do the trick:
Codeless - BL - ConsoleDemo - Backendless 2022-03-29 17-49-33

The key is to update the queryOptions property of Request Query and make sure the provided value is a list.

Regards,
Mark

1 Like