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

Prince Arora
Tera Sage
Tera Sage

@rishabh31 ,

 

From the onchange client script , can you make the checkbox "applies on requested item" to false and try again.

 

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

 

Hi @Prince Arora ,

Thanks for your response, per your advise I just tried but same result.

 

Also I checked other UI policies or Catalog client scripts but found all okay.

 

Dont know what's wrong here

@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.

Thanks @Prince Arora 

I tried the way you suggested since saw your message. I am lost with the variables tracking maybe because I need a fresh mind and thus requesting your guidance to resolve this.

 

Thanks in advance, will mark your resolution as correct and helpful.