A new enhancement in Dynamics CRM is Multiselect Option set. We Insert Value using below code in Multiselect Option set.
Syntax:- OptionSetValueCollection OPcollection = new OptionSetValueCollection() { new OptionSetValue(<value1>), new OptionSetValue(<value2>)};
Example:-
OptionSetValueCollection OPcollection = new OptionSetValueCollection() { new OptionSetValue(364760001), new OptionSetValue(364760002)};
Entity _account = new Entity("account");
_account.Attributes["name"] = "multiselect optionset test test";
_account.Attributes["new_myhobby"] = OPcollection;
var guiddata = _orgService.Create(_account);
_account.Attributes["name"] = "multiselect optionset test test";
_account.Attributes["new_myhobby"] = OPcollection;
var guiddata = _orgService.Create(_account);
We can Get Value using below code in Multiselect Option set.
Syntax:-
OptionSetValueCollection OptionCollection = (OptionSetValueCollection)entity.Attributes["<FieldName>"];
foreach (var optionSetValue in OptionCollection)
{
OptionSetValue opVal = (OptionSetValue)optionSetValue;
}
Example:-
OptionSetValueCollection OptionCollection = (OptionSetValueCollection)entity.Attributes["new_myhobby"];
foreach (var optionSetValue in OptionCollection)
{
OptionSetValue opVal = (OptionSetValue)optionSetValue;
}
foreach (var optionSetValue in OptionCollection)
{
OptionSetValue opVal = (OptionSetValue)optionSetValue;
}
Microsoft power apps is a suite of apps, data platform, connectors & services that facilitate a rapid app development environment.
ReplyDelete