why the add/romoveOptions is working in catalog form but not on RITM & SC Task

sivagangadharre
Tera Contributor

Hi,

I have a requirement that based on option1 in one variable, the other variable should only display V1&V2. If i select option2 then other variable should only display V3&V4. i have written on change client script and it is behaving as expected in service portal. But the problem is the script is not working on RITM and SC Task variables eventhough i Checked applies on RITM & task checkboxes. the second variable is showing all the options in it. any suggestion is helpful and appreciates. Thank you!

sivagangadharre_1-1681504461837.pngsivagangadharre_2-1681504560858.pngsivagangadharre_3-1681504612745.png

 

 

6 REPLIES 6

Amrit4
Tera Guru

removing an option from the variable will only work on a select box type variable not multiple choice.

Please be kind enough to mark my answer correct and Helpful

HI Amrit,

The variables that i created are select box only. not multiple choice variable. you can have a look on the screenshot added to the question. the Versino & Select version variables are select box only.

Thanks,

Siva.

 

Amrit4
Tera Guru

Try to change your script exactly like below using your variable and options. See if it works

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        addOptionAll();
        g_form.addOption("select_the_required_role", "", "--None--", "0");
        return;
    }
    addOptionAll();
    g_form.addOption("select_the_required_role", "", "--None--", "0");
    if (newValue == "AS1" || newValue == "AS2" || newValue == "AS3" || newValue == "AS5") {
        g_form.removeOption("select_the_required_role", "scbgrpthres");
        g_form.removeOption("select_the_required_role", "amanalyst");
        g_form.removeOption("select_the_required_role", "aminauditrgrp");
        g_form.removeOption("select_the_required_role", "amsupvisrgrp");
    } else if (newValue == "AS4") {
        g_form.removeOption("select_the_required_role", "exlupldadmn");
        g_form.removeOption("select_the_required_role", "scbgrpthres");
    } else if (newValue == "STH1" || newValue == "STH2" || newValue == "STH3" || newValue == "STH4" || newValue == "STH5") {
        g_form.removeOption("select_the_required_role", "exlupldadmn");
        g_form.removeOption("select_the_required_role", "amanalyst");
        g_form.removeOption("select_the_required_role", "aminauditrgrp");
        g_form.removeOption("select_the_required_role", "amsupvisrgrp");
    }

    function addOptionAll() {
        g_form.clearOptions("select_the_required_role");
        g_form.addOption("select_the_required_role", "exlupldadmn", "EXLUPLDADMN", "1");
        g_form.addOption("select_the_required_role", "scbgrpthres", "SCBGRPTHRES", "2");
//         g_form.addOption("select_the_required_role", "amanalyst", "AMANALYST3GRP", "3");
//         g_form.addOption("select_the_required_role", "aminauditrgrp", "AMINAUDITRGRP", "4");
//         g_form.addOption("select_the_required_role", "amsupvisrgrp", "AMSUPVISRGRP", "5");
    }

}

 

priyasunku
Kilo Sage

Hi @sivagangadharre 

 

As it is on chnage script it is working fine in portal. To make it work  on RITM and sc task you have to write script onload of the form as well.

 

in the same client script 

 

if(isLoading||newvalue=='')

{

copy your code here as well.

}

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful