// ** Create a string attribute **
StringAttributeMetadata stringAttribute = new StringAttributeMetadata
{
// Set base properties
SchemaName = "new_string",
DisplayName = new Label("Sample String", 1033),
RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None),
Description = new Label("String Attribute", 1033),
// Set extended properties
MaxLength = 100
};
// Create the request.
CreateAttributeRequest createAttributeRequest = new CreateAttributeRequest
{
EntityName = "EntityLogicalName",
Attribute = stringAttribute
};
// Execute the request. Get Response
CreateAttributeResponse resp = (CreateAttributeResponse)_service.Execute(createAttributeRequest);