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

倖福魔咒の 提交于 2021-01-28 05:23:25

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/60305649/dynamics-365-get-the-value-for-selected-option-from-global-option-set

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!