Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

Orderby on annotated fields via the REST API

(0) ShareShare
ReportReport
Posted on by 25

Hi there,

I need to be able to apply an orderby clause to an annotated field (i.e. order on the "Case Created" string instead of the number 4 for the statuscode field on an incident entity).

Is this possible via the REST API?

When I attempt to use statuscode@OData.Community.Display.V1.FormattedValue in the orderby I get the following error:

{"error":{"code":"0x0","message":"Syntax error at position 54 in 'statuscode@OData.Community.Display.V1.FormattedValue asc'."}}

Please note the fields could be Option Sets or Lookup fields.

I might be able to use expand on a Lookup field but I don't believe this works on Option Sets?

Regards,

Andy

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Orderby on annotated fields via the REST API

    Andy,

    I can just second what I said. You can't do it in a direct way.

    But if you're ok with alternatives - you can store the label of the optionset in some text field and do the sorting by it.

  • Andy Whitworth Profile Picture
    25 on at
    RE: Orderby on annotated fields via the REST API

    Thanks for the quick response Andrew.

    Is there no other way of doing this?

    It would be very inefficient to download a large number (could be 100s or 1000s) of incidents to then perform client-side sorting on them and would ultimately lead to a poor end-user experience in our web application.

    Regards,

    Andy

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Orderby on annotated fields via the REST API

    Hello Andy,

    I'm afraid that won't work this way. What you can do is to get the data and sort it afterward.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 225 Super User 2025 Season 1

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 106 Most Valuable Professional

#3
Eugen Podkorytov Profile Picture

Eugen Podkorytov 102

Overall leaderboard

Product updates

Dynamics 365 release plans