The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Applies to Requested item OnChange Catalog Client Script Not Working

rishabh31
Mega Sage

Dear Team,

I am facing an issue, I have an Onchange catalog client script (UI Type-All; Applies to the requested item and catalog task-True) on a Variable 'System Access' of type 'Select Box' that have more than 10 choices, I wrote below the client script

 

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        if (newValue == '') {
            g_form.setDisplay('accessA', false);

            g_form.setDisplay('accessB', false);

            g_form.setDisplay('accessC', false);

            g_form.setDisplay('accessD', false);

            g_form.setDisplay('accessE', false);

            g_form.setDisplay('accessF', false);

            g_form.setDisplay('accessG', false);
        } else
            return;
    }
    var SAcss = g_form.getValue('system_access');
    if (SAcss == 'ValueofChoice1') {
        g_form.setDisplay('accessA', true);

        g_form.setDisplay('accessB', true);

        g_form.setMandatory('accessC', false);
        g_form.setDisplay('accessC', false);

        g_form.setMandatory('accessD', false);
        g_form.setDisplay('accessD', false);

        g_form.setMandatory('accessE', false);
        g_form.setDisplay('accessE', false);

        g_form.setMandatory('accessF', false);
        g_form.setDisplay('accessF', false);

        g_form.setMandatory('accessG', false);
        g_form.setDisplay('accessG', false);
    } else if (SAcss == 'ValueofChoice2') {
        g_form.setDisplay('accessA', true);

        g_form.setDisplay('accessB', false);

        g_form.setMandatory('accessC', false);
        g_form.setDisplay('accessC', false);

        g_form.setMandatory('accessD', false);
        g_form.setDisplay('accessD', false);

        g_form.setMandatory('accessE', false);
        g_form.setDisplay('accessE', false);

        g_form.setMandatory('accessF', false);
        g_form.setDisplay('accessF', false);

        g_form.setMandatory('accessG', false);
        g_form.setDisplay('accessG', false);
    } else if (SAcss == 'ValueofChoice3') {
         g_form.setDisplay('accessA', false);

        g_form.setDisplay('accessB', false);

        g_form.setMandatory('accessC', true);
        g_form.setDisplay('accessC', true);

        g_form.setMandatory('accessD', false);
        g_form.setDisplay('accessD', false);

        g_form.setMandatory('accessE', false);
        g_form.setDisplay('accessE', false);

        g_form.setMandatory('accessF', false);
        g_form.setDisplay('accessF', false);

        g_form.setMandatory('accessG', false);
        g_form.setDisplay('accessG', false);
    } else if (SAcss == 'ValueofChoice4') {
    g_form.setDisplay('accessA', false);

        g_form.setDisplay('accessB', false);

        g_form.setMandatory('accessC', false);
        g_form.setDisplay('accessC', false);

        g_form.setMandatory('accessD', true);
        g_form.setDisplay('accessD', true);

        g_form.setMandatory('accessE', false);
        g_form.setDisplay('accessE', false);

        g_form.setMandatory('accessF', false);
        g_form.setDisplay('accessF', false);

        g_form.setMandatory('accessG', false);
        g_form.setDisplay('accessG', false);
    } else if (SAcss == 'ValueofChoice5') {
        g_form.setDisplay('accessA', false);

        g_form.setDisplay('accessB', false);

        g_form.setMandatory('accessC', false);
        g_form.setDisplay('accessC', false);

        g_form.setMandatory('accessD', false);
        g_form.setDisplay('accessD', false);

        g_form.setMandatory('accessE', true);
        g_form.setDisplay('accessE', true);

        g_form.setMandatory('accessF', false);
        g_form.setDisplay('accessF', false);

        g_form.setMandatory('accessG', false);
        g_form.setDisplay('accessG', false);
    } else if (SAcss == 'ValueofChoice6') {
       g_form.setDisplay('accessA', false);

        g_form.setDisplay('accessB', false);

        g_form.setMandatory('accessC', false);
        g_form.setDisplay('accessC', false);

        g_form.setMandatory('accessD', false);
        g_form.setDisplay('accessD', false);

        g_form.setMandatory('accessE', false);
        g_form.setDisplay('accessE', false);

        g_form.setMandatory('accessF', true);
        g_form.setDisplay('accessF', true);

        g_form.setMandatory('accessG', false);
        g_form.setDisplay('accessG', false);
    } else if (SAcss == 'ValueofChoice7') {
         g_form.setDisplay('accessA', false);

        g_form.setDisplay('accessB', false);

        g_form.setMandatory('accessC', false);
        g_form.setDisplay('accessC', false);

        g_form.setMandatory('accessD', false);
        g_form.setDisplay('accessD', false);

        g_form.setMandatory('accessE', false);
        g_form.setDisplay('accessE', false);

        g_form.setMandatory('accessF', false);
        g_form.setDisplay('accessF', false);

        g_form.setMandatory('accessG', true);
        g_form.setDisplay('accessG', true);
    } else if (SAcss == 'ValueofChoice8' || SAcss == 'ValueofChoice9' || SAcss == 'ValueofChoice10' || SAcss == 'ValueofChoice11' ||
        SAcss == 'ValueofChoice12' || SAcss == 'ValueofChoice13' || SAcss == 'ValueofChoice14' || SAcss == 'ValueofChoice15' ||
        SAcss == 'ValueofChoice16' || SAcss == 'ValueofChoice17') {
       g_form.setDisplay('accessA', false);

            g_form.setDisplay('accessB', false);

            g_form.setDisplay('accessC', false);

            g_form.setDisplay('accessD', false);

            g_form.setDisplay('accessE', false);

            g_form.setDisplay('accessF', false);

            g_form.setDisplay('accessG', false);
    }
}

 

This script is working perfectly but the issue I am facing is even though I filled in these details and submitted a request (below is the screenshot of the 'additional details' tab post successful submission of request), the highlighted 2 variables- 

1st- Which properties do you require access to? (Variable Name: properties_access_require) & 2nd- What TCODE(s) do you require access to? (Variable Name: TCODE_require_access_to), are not displaying  rishabh31_1-1681635032406.png
on its associated RITM (screenshot attached below)
rishabh31_2-1681635804748.png

Please note this is happening for all other variables as well, but if this gets sorted so will apply same technique to other variables so that it will display on RITM.

Further would also like to inform you that I am unable to get this achieved through UI Policy as well to display the variables on RITM even though that was also applied to RITM and SCTASK.

Can anyone please help me to resolve this, I shall be grateful. Thanks

 

1 ACCEPTED SOLUTION

@rishabh31 ,

 

1) Please ensure that variables are the part of catalog item (if it is from variable set, might be a script has written over there).

 

2) To debug, make all the scripts active false and track the variables on RITM, then make each script active true one by one until you find the culprit.

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

View solution in original post

8 REPLIES 8

@rishabh31 ,

 

Please make "applies to requested item" active false on all the scripts and then try again, It would be visible 100%

Hello @Prince Arora , this is resolved now, something new I learnt here while debugging per your advice I found my 2 catalogs on change client scripts are conflicting with each other because these are written on 2 different variables of type select box that have mostly the same or common choices in it and its associated variables get displayed depending upon identical conditions of other variable's choice selection, this is why system got confused b/w both scripts with identical conditions, so made them false and used UI policy with proper condition placement resolved this. Now variables are properly displaying on RITM (Applies on Requested Item working properly) and also form is also working as expected.

@rishabh31 

 

Glad to hear that your issue has fixed 🙂

Happy Coding 🙂

OlaN
Giga Sage
Giga Sage

Hi,

The variables aren't showing because in your onChange client script you have lines that hide those variables in the onLoad section.

See below, copied from your script:

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        if (newValue == '') {
            g_form.setDisplay('properties_access_require', false); // this will hide the variable when the page loads

            g_form.setDisplay('TCODE_require_access_to', false); // this will hide the variable when the page loads

...