Monday, May 7, 2012

Create an Option Set in Microsoft Dynamics CRM 2011 Using VB.NET

This illustration shows how to create an option set in Microsoft Dynamics CRM 2011 using VB.NET with the CreateOptionSet Request.   This example will be given in VB.NET.

Ok, here is what the code look like!
In VB.NET:

Dim req As New CreateOptionSetRequest()
Dim omd As New OptionSetMetadata()
omd.Name = "new_optionsettest"
omd.DisplayName = New Label("Example Option Set", 1033)
omd.IsGlobal = True
omd.OptionSetType = OptionSetType.Picklist
omd.Options.Add(New OptionMetadata(New Label("Green", 1033), Nothing))
omd.Options.Add(New OptionMetadata(New Label("Yellow", 1033), Nothing))
omd.Options.Add(New OptionMetadata(New Label("Blue", 1033), Nothing))
omd.Options.Add(New OptionMetadata(New Label("Brown", 1033), Nothing))

req.OptionSet = omd

Dim resp As CreateOptionSetResponse = DirectCast(service.Execute(req), CreateOptionSetResponse)



I hope this helps!

-

No comments:

Post a Comment