Sorting a field in a 1:1 relation

Hi,

I am running a query in REST console on a table (Retailer) which has a relationship with another table (Locations).

I am using this query

where=retailerid=6&loadRelations=locations&relationsPageSize=50

Is it possible to sort on a field in the Locations table?

Thanks
Steve

Hello @Steve,

Yes, you can sort on a field in the Locations table by using the sortBy parameter. For example, to sort by the city field in ascending order, you can modify your query like this:

where=rating%3D6&sortBy=%60locations%60.%60city%60%20asc&loadRelations=locations&relationsPageSize=50

Regards,
Alexander

Hi,

I tried that but it didn’t work -

Steve

Hi @Steve

The solution proposed by Alexander works well for 1:1 relations.
However, in your case, you are dealing with 1:N relations.

As a result, the list of objects retrieved from the relation table locations is returned sorted by objectId, and this sorting cannot be changed within this query.

However, you can try using a different approach. Please take a look at this documentation: Two steps retrieval

Regards,
Viktor