Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

Hide one of the Request category option when a specific ci is selected in Catalog item

VishakhaShi
Tera Contributor

User has a requirement : In a catalog item, when a 'ABC' ci is selected ,  'XYZ' option of request category field should be removed from option.

For this , i used the below script but its not working:

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    var ci = g_form.getValue('configuraion_item');
 
     if (ci == 'CI sys id') {
        var options = g_form.getOptions('request_category');
 
         for (var i = 0; i < options.length; i++) {
            if (options[i].value == 'access_privilege') {
                g_form.removeOption('request_category', options[i].value);
            }
        }
    } else {
       
      g_form.addOption('request_category', 'access_privilege', 'Access & Privilege');
    }
}

 

What is the error here?

1 ACCEPTED SOLUTION

@VishakhaShi You can specify the reference qualifier in the Type specification tab of your look up select box variable.

 

Screenshot 2024-08-26 at 6.06.16 PM.png

View solution in original post

8 REPLIES 8

@VishakhaShi You need to use Advanced reference qualifier to which will filter the choices based on the value in the CI variable.

 

Please mark my response helpful and accepted solution if it addressed your question.

@VishakhaShi Please mark the response an accepted solution too.

Where to use this reference qualifier exactly? 

@VishakhaShi You can specify the reference qualifier in the Type specification tab of your look up select box variable.

 

Screenshot 2024-08-26 at 6.06.16 PM.png