MS Dynamics CRM 2011 Metadata-Create New Attribute

As you would have guessed Adam wants to know about creating an attribute. Let’s call this attribute ‘honesty’. Lets assume its an attribute of type String. This is represented by the type ‘StringAttributeMetadata’.

We will use the CreateAttributeRequest Message with Execute method of Organization service to create the attribute. CreateAttributeRequest takes entity name and the attribute metadata.

Lets first create attribute metadata. Let’s assume we are adding the ‘honesty’ attribute to our entity ‘human’ (created here). This is how you can do it.

var honestAttribute = new StringAttributeMetadata
SchemaName = “honesty”,
LogicalName = “honesty”,
DisplayName = new Label(“Honesty”, 1033),
RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.Recommended),
Description = new Label(“Honesty is the best policy”, 1033),
MaxLength = 50

Create attribute

CreateAttributeRequest createAttributeRequest = new CreateAttributeRequest
EntityName = “human”,
Attribute = honestAttribute


Easy isn’t it? I wish it was that easy to add honesty to humans. Anyways so lets see what Adam would like to learn next.