查找Dynamics CRM实体属性的依赖项
本文关键字:依赖 属性 实体 Dynamics CRM 查找 | 更新日期: 2023-09-27 17:51:16
我正在努力从c#代码中找到CRM实体属性的依赖项,但我找不到正确的方法。
代码如下:
var attributeRequest = new RetrieveAttributeRequest
{
EntityLogicalName = "invoice",
LogicalName = "billto_city"
};
var attributeResponse = (RetrieveAttributeResponse)proxy.Execute(attributeRequest);
var dependenciesRequest = new RetrieveDependenciesForDeleteRequest
{
ObjectId = (Guid)attributeResponse.AttributeMetadata.MetadataId,
ComponentType = (int)attributeResponse.AttributeMetadata.AttributeType
};
var dependenciesResponse = (RetrieveDependenciesForDeleteResponse)proxy.Execute(dependenciesRequest);
给出阴性结果。我认为使用属性MetadataId
作为ObjectId
是不正确的。但似乎不可能找到ObjectId
作为属性。
以前有人遇到过类似的任务吗?你是怎么解决的?
使用AttributeMetadata。AttributeType属性,它指示属性的类型(字符串、查找、选择列表、布尔值等),但您需要componenttype值,这是解决方案组件的类型(实体、属性、关系、选项集等)。在你的例子中是2。完整的组件类型和代码表可以在这里找到。