Thursday, March 29, 2012

Add a Custom Attribute to an Entity in Microsoft Dynamics CRM 2011 Using VB.NET

This illustration will show you how to add a new custom attribute to an entity in Microsoft Dynamics CRM 2011 using VB.NET.

Ok, here is what the code looks like once your service is instantiated!

In VB.NET

Dim attribute As New StringAttributeMetadata
attribute.SchemaName = "new_stringattribute"
attribute.DisplayName = New Label("sample string  attribute", 1033)
attribute.RequiredLevel = New AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None)
attribute.Description = New Label("string attribute", 1033)
attribute.MaxLength = 100

Dim req As New CreateAttributeRequest
req.EntityName = "account"
req.Attribute = attribute
Dim resp As CreateAttributeResponse = DirectCast(service.Execute(req), CreateAttributeResponse)


Thats all there is to it!
-

No comments:

Post a Comment