How to get attribute meta data for an entity

Posted on Posted in CRM 2011 SDK, MS CRM 2011, MS Dynamics CRM

How to get attribute meta data for an entity

We have org name and entity name
We can use method below to get Entity first

var entityData = Crm2011Services.EntityMetadata(orgName, entityName);

This will get us all data related to entity
Now we can loop thorugh attributes
Dictionary<string, AttributeMetadata> entityAttributes = new Dictionary<string, AttributeMetadata>();
foreach (AttributeMetadata attribute in entityData.Attributes)
{
string name = attribute.LogicalName;
entityAttributes.Add(name, attribute);
}