Skip to content

Instantly share code, notes, and snippets.

@melamriD365
Last active February 27, 2021 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melamriD365/02b88ec03b6d8567294f514d7e6f8618 to your computer and use it in GitHub Desktop.
Save melamriD365/02b88ec03b6d8567294f514d7e6f8618 to your computer and use it in GitHub Desktop.
if(typeof(MEA)=="undefined"){MEA={}};
if(typeof(MEA.OptionSet)=="undefined"){MEA.OptionSet={}};
if(typeof(MEA.OptionSet.Utilities)=="undefined"){MEA.OptionSet.Utilities={}};
MEA.OptionSet.Utilities = {
//Cascading Utility
optionSetBValues : null,
Cascade: function (executionContext, optionAName, optionBName, dependecies) {
var formContext = executionContext.getFormContext();
var selectedAValue = formContext.getAttribute(optionAName).getValue();
var optionSetBControl = formContext.getControl(optionBName);
if (optionSetBValues == null)
optionSetBValues = optionSetBControl.getOptions();
if (selectedAValue != null) {
optionSetBControl.clearOptions();
var dependeciesB = dependecies.find(d => d[0] == selectedAValue).slice(1);
var filtredOptionB = optionSetBValues.filter(v => dependeciesB.includes(v.value));
filtredOptionB.forEach(d => {
optionSetBControl.addOption(d);
})
}
else {
optionSetBControl.clearOptions();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment