Friday, March 30, 2012

Delete A Custom Attribute From an Entity in Microsoft Dynamics CRM 2011 Using VB.NET

This illustration will show you how to delete a custom attribute from an entity in Microsoft Dynamics CRM 2011 using VB.NET to invoke DeleteAttributeRequest.

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 DeleteAttributeRequest
req.EntityLogicalName = "account"
req.LogicalName = attribute.SchemaName
Dim resp As DeleteAttributeResponse = DirectCast(service.Execute(req), DeleteAttributeResponse)


Thats all there is to it!
-

No comments:

Post a Comment