如何在CRM 2016中检索实体名称 [英] How to retrieve entity names in CRM 2016
问题描述
在我们的解决方案中,我们正在动态构建HTTP/ODATA请求.
In our solution, we are building HTTP/ODATA requests dynamically.
例如,我们将构建一个如下所示的URL:
For example, we will build a URL that looks like this:
[http://org....api/v8.1/]accounts(00000000-0000-0000-0000-000000000001)/primarycontactid?$select=fullname
我们如何动态获取所有实体(例如帐户")的列表?
在2011年,我们将仅针对LeadSet/AccountSet/etcSet执行, 2016年的策略是什么?
In 2011, we would simply execute against LeadSet/AccountSet/etcSet, what is the strategy in 2016?
推荐答案
我不知道是否存在一些语言"技巧(显然,集合的名称只是实体英文的复数名称,但是那不是对我来说足够好),所以我就这样-只需调用webAPI元数据:
I don't know if there is some "language" trick (obviously the name of the set is just plural name in english of the entity, but that's not good enough for me), so I it like that - simply call webAPI metadata:
http://[crmurl]/api/data/v8.2/EntityDefinitions?$select=EntitySetName,LogicalName&$filter=LogicalName eq 'account'
结果如下:
{
"@odata.context":"http://[crmurl]/api/data/v8.2/$metadata#EntityDefinitions(EntitySetName,LogicalName)","value":[
{
"EntitySetName":"accounts","LogicalName":"account","MetadataId":"70816501-edb9-4740-a16c-6a5efbc05d84"
}
]
}
这样您就知道了.当然,您只需跳过$filter
部分,只需获取所有集合名称的列表并将它们缓存在某个位置即可.
So you get the idea. Of course you can simply skip the $filter
part and simply get list of all set names and cache them somewhere.
这篇关于如何在CRM 2016中检索实体名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!