【发布时间】:2016-12-07 22:22:17
【问题描述】:
我有一些通过 Dynamics CRM Web API 执行的 fetchXml。 fetchXml 查询的构造如下:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="new_someEntityA">
<attribute name="new_lookupForSomeEntityA" />
<link-entity alias="new_someEntityB" name="new_someEntityB" from="entityBId" to="entityAId" visible="false" link-type="outer">
<attribute name="new_lookupForSomeEntityB" />
</link-entity>
</entity>
</fetch>
当我通过 Web API 发送此查询时,我会收到响应,并且“new_lookupForSomeEntityA”的值包括值 (GUID) 和格式化值(它的名称)。但是“new_lookupForSomeEntityB”的响应只包括 GUID,我找不到获取它的 GUID 和值的方法。我添加了一个标题记录:
"Prefer": "odata.include-annotations=OData.Community.Display.V1.FormattedValue"
但这似乎只是让我获得了主要实体的格式化值,而不是链接实体。这是 Web API 的限制还是我做错了什么?任何帮助将不胜感激。
【问题讨论】:
-
您是否尝试将名称属性添加到
<link-entity>节点? -
是的,我试过了。在 SQL 中,该属性是“new_lookupForSomeEntityBName”,如果我添加它,我会得到一个返回,说明该属性不存在。如果我使用“名称”(小写),查询返回,但仍然只有一个 GUID,没有查找名称。
-
您需要在实体 new_someEntityB 上指定名称属性的名称。您可以在实体主选项卡上的 CRM 解决方案中查找它。在 SQL 中,
new_lookupForSomeEntityBName是过滤视图的列,映射到实际表的主字段名称。 -
我将其更改为:
<link-entity alias="new_someEntityB" name="new_someEntityB" name-attribute="new_name" from="entityBId" to="entityAId" visible="false" link-type="outer"> <attribute name-attribute="new_name" name="new_lookupForSomeEntityB" /> </link-entity>当我这样做时,我得到与返回值相同的 id,只是:new_someEntityB_x002e_new_lookupForSomeEntityBid: [GUID] -
不要使用
name-attribute属性,而只能使用<attribute name="new_name"/>。
标签: dynamics-crm dynamics-crm-online dynamics-crm-2016 fetchxml dynamics-crm-webapi