Skip to main content

Notifications

Announcements

No record found.

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?

Posted on by 15

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

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: api returning numerical value for status and other choice field. is there way to get exact status value?

    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.

  • Suggested answer
    RE: api returning numerical value for status and other choice field. is there way to get exact status value?

    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
    Pavan Deepala Profile Picture
    Pavan Deepala 90 on at
    RE: api returning numerical value for status and other choice field. is there way to get exact status value?
    [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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans