Working with Multi Select Option Set using C# in Dynamics 365.
Hi All,
Introduction:
Microsoft introduced a new data type called Multi Select Option Set in Dynamics 365 v9.0, using Multi Select Option Set we can select more than one option set in Dynamics 365.
It contains a list of Options and we can select more than one option from the list on selecting the checkboxes and also we can search the option from the list of options.
Create a filed in CRM like below:
Add this filed on the Form.
Below code is used for saving the Multi Select Option Set using the C# code.
Find the result in below screen.
Try this code once.
Thank you.
Best Regards,
Pavan Kumar K.
Introduction:
Microsoft introduced a new data type called Multi Select Option Set in Dynamics 365 v9.0, using Multi Select Option Set we can select more than one option set in Dynamics 365.
It contains a list of Options and we can select more than one option from the list on selecting the checkboxes and also we can search the option from the list of options.
Create a filed in CRM like below:
Add this filed on the Form.
Click on Save and Publish.
Below code is used for saving the Multi Select Option Set using the C# code.
public static void CreateRecordwithMultiSelectOptionSet()
{
Entity entity = new Entity("new_employee");
entity.Attributes["new_name"] = "Ram";
int[] optionsetValues = { 100000000, 100000001 };
OptionSetValueCollection collection = new OptionSetValueCollection();
foreach (var item in optionsetValues)
{
collection.Add(new OptionSetValue(item));
}
entity.Attributes["new_interustedin"] = collection;
Guid recordId = service.Create(entity);
Console.WriteLine(string.Format("Record Created with Id: {0}", recordId));
Console.ReadLine();
}
Find the result in below screen.
For setting single option value in Multi Select Option Set use the below code:
OptionSetValueCollection collection = new OptionSetValueCollection();
OptionSetValue optionSet = new OptionSetValue(100000000);
collection.Add(optionSet);
entity.Attributes["new_interustedin"] = collection;
Try this code once.
Thank you.
Best Regards,
Pavan Kumar K.
Comments
Post a Comment