Reputation: 9538
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?
Upvotes: 6
Views: 2192
Reputation: 178
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.
Upvotes: 3