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

api returning numerical value for status and other choice field. is there way to get exact status value?

(0) ShareShare
ReportReport
Posted on by 15

api returning numerical value for status and other choice field. is there way to get exact status value?

I have the same question (0)
  • Suggested answer
    Pavan Deepala Profile Picture
    90 on at
    [quote user="Microsoft Retail"]

    api returning numerical value for status and other choice field. is there way to get exact status value?

    [/quote]

    What do you mean by exact status value ? Are you referring to text value ? If so

    By default all option sets return the numeric value for API calls. If you want to get the Text value you need to include formatted values header in your request.

    Please refer https://docs.microsoft.com/en-us/dynamics365/omnichannel/administrator/routing-trigger

  • Suggested answer
    Filipe Relvas Profile Picture
    on at

    Hello,

    Through the Web API you could do something like this:

    [Organization URI]/api/data/v8.2/EntityDefinitions(LogicalName='[Entity Name]')/Attributes(LogicalName='[Your Field Name Which uses OptionSet]')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$expand=OptionSet($select=Options),GlobalOptionSet($select=Options)

    In the response you will have something like this:

    "Options": [{

               "Value": 1,

               "Color": null,

               "IsManaged": true,

               "ExternalValue": null,

               "MetadataId": null,

               "HasChanged": null,

               "Label": {

                   "LocalizedLabels": [{

                       "Label": "Competitor",

                       "LanguageCode": 1033,

                       "IsManaged": true,

                       "MetadataId": "6c54c2fa-2241-db11-898a-0007e9e17ebd",

                       "HasChanged": null

                   }],

                   "UserLocalizedLabel": {

                       "Label": "Competitor",

                       "LanguageCode": 1033,

                       "IsManaged": true,

                       "MetadataId": "6c54c2fa-2241-db11-898a-0007e9e17ebd",

                       "HasChanged": null

                   }

               },

               "Description": {

                   "LocalizedLabels": [],

                   "UserLocalizedLabel": null

               }

           },

           {

               "Value": 2,

               "Color": null,

               "IsManaged": true,

               "ExternalValue": null,

               "MetadataId": null,

               "HasChanged": null,

               "Label": {

                   "LocalizedLabels": [{

                       "Label": "Consultant",

                       "LanguageCode": 1033,

                       "IsManaged": true,

                       "MetadataId": "6e54c2fa-2241-db11-898a-0007e9e17ebd",

                       "HasChanged": null

                   }],

                   "UserLocalizedLabel": {

                       "Label": "Consultant",

                       "LanguageCode": 1033,

                       "IsManaged": true,

                       "MetadataId": "6e54c2fa-2241-db11-898a-0007e9e17ebd",

                       "HasChanged": null

                   }

               },

               "Description": {

                   "LocalizedLabels": [],

                   "UserLocalizedLabel": null

               }

           }

    Keep in mind that if you change the Labels for those options you will need to change the code, while this wouldn't be necessary if you use the Option GUID instead.

    Hope this helps!

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at

    Hi,

    You need to set below in request header to get the text value of option set field.

    Prefer: odata.include-annotations="OData.Community.Display.V1.FormattedValue"  

    docs.microsoft.com/.../query-data-web-api

    If found helpful, Please mark my answer verified.

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