问题描述
我试图找到一种方法来获取基于GlobalOptionSet的字段的值.我正在设法从端点拉回数据
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 endpointhttps://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");
这篇关于Dynamics 365-从全局选项集中获取所选选项的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!