Suppose the following scenario, you have an option set on a Dynamics CRM 2011 form and you want
to change the selected item or it have no selected item currently and you would like to set it.
You have to 2 ways to do it.
- By ValueXrm.Page.getAttribute(“optionsetAttribute”).setValue(value);
- By TextActually you can’t set the selected item by text by you can search all options untill you find the on whose text (label) is the same as one the one you have then get its valuesetOptionSetByOptionText = function(optionsetAttribute, optionText)
{
var options = Xrm.Page.getAttribute(optionsetAttribute).getOptions();for(i = 0; i < options.length; i++)
{if (options[i].text == optionText)Xrm.Page.getAttribute(optionsetAttribute).setValue(options[i].value);}
}Example : setOptionSetByOptionText (“new_nationality”,”American”);
No comments:
Post a Comment