简体   繁体   中英

Dynamics 365 - Get the value for selected option from Global Option Set

I'm trying to find a way to get a value for my field which is based on a GlobalOptionSet. I'm managing to pull back data from my endpoint https://TEST.test.dynamics.com/api/data/v9.1/projects which is returning my list of projects. some of the fields on this dataset just show as GUID's which I've managed to expand into and get their values. However, some of the fields returned are showing just numbers like 866110000 which I believe is an option in a GlobalOptionSet.

I know I can get the GlobalOptionSet definition and match up its value but I'm hoping to be able to get this information in a single query similar to the way I got other fields by expanding.

Does anyone know how to get it to return the selected Value for an option field instead of the ID of the option that was picked?

Thanks

All you have to do is include the below header to get the needed optionset & lookup display name values. Read more

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

Sample request:

GET [Organization URI]/api/data/v9.1/accounts?$select=name,donotpostalmail,accountratingcode,numberofemployees,revenue
&$top=1 HTTP/1.1  
Accept: application/json  
OData-MaxVersion: 4.0  
OData-Version: 4.0  
Prefer: odata.include-annotations="OData.Community.Display.V1.FormattedValue"

If its AJAX request using jQuery or XmlHttpRequest, for ex.

req.setRequestHeader("Prefer", "odata.include-annotations=OData.Community.Display.V1.FormattedValue"); 

在此处输入图片说明

Reference

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM