Monday, March 25, 2013

CRM 2011 JS : Set Option Set Value By Text

 function SetOptionSetValueByText(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);  
  }  
 }  


Function calling
SetOptionSetValueByText("new_country","USA");

No comments:

Post a Comment