How to retrieve formatted values of lookups in an entity?

你说的曾经没有我的故事 提交于 2021-02-16 15:44:27

问题


We are facing challenge in getting formatted values of lookups available in an entity using web api.

Scenario: we have an entity with 8 lookups. When I'm querying those with Web API, getting GUIDs of those lookups, but not the names of those lookups.


回答1:


MSDN says adding header in web api request Prefer: odata.include-annotations="*" will result you the formatted value - Name, logical name along with Id like below: (without making another call)

req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");

-

   "_customerid_value@Microsoft.Dynamics.CRM.associatednavigationproperty":"customerid_contact",
   "_customerid_value@Microsoft.Dynamics.CRM.lookuplogicalname":"contact",
   "_customerid_value@OData.Community.Display.V1.FormattedValue":"Susanna Stubberod (sample)",
   "_customerid_value":"7ddd0b31-ed8b-e511-80d2-00155d2a68d4",



回答2:


You can not retrieve formatted values in WebApi. you should retrieve your lookup name or any other detail(field) by a second call and retrieve name or any field of lookup using its GUID



来源:https://stackoverflow.com/questions/47237971/how-to-retrieve-formatted-values-of-lookups-in-an-entity

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