web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

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

I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello Andy,

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

  • Andy Whitworth Profile Picture
    25 on at

    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

    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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 70 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 33 Most Valuable Professional

#3
Daniyal Khaleel Profile Picture

Daniyal Khaleel 32 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans