简体   繁体   中英

Find dependencies for Dynamics CRM entity's attribute

I'm struggling to find dependencies for CRM entity attribute from C# code, but I cannot find the right way.

The code like this:

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);

Gives negative result. I suppose it's incorrect to use attribute MetadataId as ObjectId . But it seems it is impossible to find out ObjectId for attribute.

Does anybody faced with similar task before? How did you solve it?

You use AttributeMetadata.AttributeType property, which indicates the type of attribute (string, lookup, picklist, boolean etc.) but you need the componenttype value, which is type of solution component (Entity, Attribute, Relationship, Option Set etc.). In your case its 2. The full table of component types and their codes may be found here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM