I written this script for the multiselect field for the option visibility, when I select Option 1 in multiselect field it is going to if condition and if I select both the options in multiselect field it is not passing to else statement still stays in the "1st If condition of OPTION1"
I'm looking in a way when I select multiple option in multiselect field it should directly move to else statement by skipping the if conditions and if I select the single option it should look to IF condition
Below is the code I written
if(changeField.getName() == "Select List (Multi)")
{
let podName = field.getValue()
let value = podName.map(c => c.value)
if(value.toString().includes("Option 1")){
getFieldById("customfield_10047").setOptionsVisibility(["10130","10026"],true)
}
else if(value.toString().includes("Option 2")){
getFieldById("customfield_10047").setOptionsVisibility(["10027"],true)
}
else{
getFieldById("customfield_10047").setOptionsVisibility(["10026", "10027", "10130", "10154"],true)
}
Hello @Imran Khan
Hope you're doing well !
I Would do something like this with feld I created for the matter of the example( tested on my instance and working fine):
const colorField = getFieldById("customfield_10088") // Single select
const colorsField = getFieldById("customfield_10093") // Multi select
const changedField = getChangeField()
const colorsValue = colorsField.getValue().map(c => c.value)
const colorsValueString = colorsValue.toString();
if (changedField.getName() == colorsField.getName()) {
const hasRed = colorsValueString.includes("Red");
const hasBlue = colorsValueString.includes("Blue");
const hasGreen = colorsValueString.includes("Green");
if (hasRed || hasBlue || hasGreen) {
colorField.setRequired(true);
let options = [];
if (hasRed) options.push("10156");
if (hasBlue) options.push("10157");
if (hasGreen) options.push("10158");
colorField.setOptionsVisibility(options, true);
}
}
Hope this help.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.