api returning numerical value for status and other choice field. is there way to get exact status value?
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
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!
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
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,269 Super User 2024 Season 2
Martin Dráb 230,198 Most Valuable Professional
nmaenpaa 101,156