User Review
( votes)Overview:
In this article, we are going to see how to create a custom option set field and add dynamic options to the custom option set using JavaScript.
Step 1: Create an Option set field and add one option.
Step 2: Declare an array and Store three values.
Step 3: Write the script below.
function setOptions(executionContext)
{
var formContext = executionContext.getFormContext();
var optionCode = formContext.getControl(arg);
optionCode.clearOptions();
countryArray = [“India”,”Singapore”,”Malaysia”];
var index = 1;
for (var i=0; i< countryArray.length; i++)
{
var Name = countryArray[i];
var obj = {};
obj[“text”] = Name;
obj[“value”] = index;
optionCode.addOption(obj);
index = index + 1;
}
}
Step 4: Deploy the Web resource and add the function on the OnLoad event of the form.
Output:
Hope it helps and Power 365ing as usual!
Any problem in Power Platform or Dynamics 365 – end user, Microsoft partner or an individual?
Problem Area – Technical, Functional, Training, Development or consulting?
I am here to help, get in touch here: Click here