show values in reference field search based upon the choices in another field

kiran kumar m1
Tera Contributor

I have 2 fields one is Geo (choice) field and another is location(reference) field . In my location field i have over rided the reference qualifier and kept 3 locations India, Philippines, Mexico . Now in geo field i have two options NA and APAC . Now I need a functionality such that if I select NA in the geo field the search box in the location field should have only Mexico as location to select similarly if i select APAC only India and Philippines should be visible to select .   How can I achieve this ?

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

You should be able to do this all within the reference qualifier like this:

BradBowman_0-1726875345371.png

 

var ret='sys_idIN';if(current.u_geo == 'NA'){ret += 'sys_id of Mexico';}else{ret += 'sys_id of India, sys_id of Philippines';}ret;

 

Where u_geo is the choice field name, which has the actual value of 'NA', 

View solution in original post

9 REPLIES 9

Gangadhar Ravi
Giga Sage
Giga Sage

@kiran kumar m1 You can implement advanced reference qualifier. Please refer this 

 

https://servicenowguru.com/script-includes-scripting/advanced-reference-qualifier-script-include/

 

Please mark my answer correct and helpful if this works for you.

Brad Bowman
Kilo Patron
Kilo Patron

You should be able to do this all within the reference qualifier like this:

BradBowman_0-1726875345371.png

 

var ret='sys_idIN';if(current.u_geo == 'NA'){ret += 'sys_id of Mexico';}else{ret += 'sys_id of India, sys_id of Philippines';}ret;

 

Where u_geo is the choice field name, which has the actual value of 'NA', 

Hi @Brad Bowman  , thanks for your quick reply. Actually this is for a custom application , earlier I have dictionary overrided the location field and hardcoded the 3 locations sys ids . Now I have removed that and pasted your reference qualifier ,but its showing all the locations instead of those three .  

kirankumarm1_0-1727099143104.png

 

When you see all of the records, something in the qualifier is invalid or it otherwise doesn't resolve correctly.  In this case it looks like you have a semi-colon instead of a colon after javascript, and remove the << >> - I was just using those symbols to try to call attention to what needed to be replaced.  I also transposed the { } brackets.  I corrected this in the earlier response.