Filter a Lookup select box based on another lookup select box selection

nicolemccray
Tera Expert

I have a script that has worked in the past for filtering a list collector based on the lookup select box selection, but not sure how to modify the script to filter a 'lookup select box' based on another lookup select box:

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }

   //Type appropriate comment here, and begin script below
    var filterString = "";
 
 //Look for Application
 var pf = g_form.getValue('application');
 
 
 //Concat to filter   u_platform=cba
 if(pf != "") filterString += "^u_platform="+pf;
 else if(pf != "") filterString = "u_platform="+pf ;

 
 var roleCat= 'role_cat';
       window[roleCat + 'g_filter'].reset();
         window[roleCat + 'g_filter'].setQuery(filterString);
         window[roleCat + 'acRequest'](null);
}

 

When user selects the 'application', the second lookup select box should only show those values associated with that application:

First field in the form: application (column name in the table is 'u_platform')

Second field on the form I need to filter: role_cat

 

1 ACCEPTED SOLUTION

Upender Kumar
Mega Sage

Hi,

 

To bind first variable use

find_real_file.png

 

For dependent filed use Reference qual

 

 

find_real_file.png

 

find_real_file.png

 

 

find_real_file.png

View solution in original post

7 REPLIES 7

you can get it by changing form layout

 

find_real_file.png

It was already on the form but still did not display.  I had to make the field a reference field then change it to a lookup as noted in this post: https://community.servicenow.com/community?id=community_question&sys_id=7d93c765dbd8dbc01dcaf3231f961994

Thank you for detailed explanation. It really helped me a lot.