Reference Qualifier on Lookup Select Box Variable

Blair5
Tera Guru

I've been looking through the WIKI/community and it seems like there is a bug with reference qualifiers on Lookup Select box variables. Does anyone know if there is a work around besides making the field a reference variable?

I have 3 variables on a form -- each dependent on the last. The first is a lookup select box and I'd like the second to be a lookup select box with a reference qualifier because setting it as a reference variable gives the same information as the third variable. I've tried only showing the columns I want (with attributes), but it still shows too much.

Is there another angle I can take? Building the list with a script? I only want to show unique values. Any ideas/help would be greatly appreciated because I think I've exhausted all the options I can think of. Thanks!

1 ACCEPTED SOLUTION

Kalaiarasan Pus
Giga Sage

Seems like we all have been trolled here Look up select supports reference qualifier but it's not simple as reference field..



Check the wiki page



http://wiki.servicenow.com/index.php?title=Variable_Types#Lookup_Select_Box



We need to use 'ref_qual_elements' attribute to get the updated reference working..


I am able to do the dynamic thing working after adding the attribute...



Sample demo:



Create 2 lookup select variable called 'located_at' and 'user' referring location and user table respectively.


Idea here is to display the user depending on the location selected...


In the user variable, define reference qual as javascript: 'location='+current.variables.located_at; and variable attribute as ref_qual_elements=located_at



This will make the variable to use the updated reference. Try this out and let me know if this works for you as well.



Note: I tried on Fuji instance.


View solution in original post

78 REPLIES 78

Spoke too soon, got it working finally! In my reference qual, I had to pull the value of the department field on the division's table, which is u_department. Once that got placed in, it started to work.


2016-06-13_15-24-06.png



Talk about a finicky process!


Apologies I couldn't get back to you on this soon. Glad you got it working !!!


This does not work in the new service portal it works on the same item in the old CMS I couldn't figure out why its not working in the Service portal.   Anyone else experiencing this issue? or have a workaround where i dont have to script an onChange client script?


Samhitha
Tera Contributor

It Worked like a charm!!!!

ark6
Mega Guru

Hi Sean/All,



I had also made it work in the catalog view, but the same is not working in portal.



I haven't found out a way to do it in SP, so I reverted back to my old select box where I have all the values and used an onchange script to ad options



My Scenerio: I have country, state, city fields which are dependent on each other and referencing cmn_location table. So, I have written a catalog client script to make them work instead(for me these fields shud be repeated thrice like loc1, loc 2, loc3 and above soultion was working for only one set in SP .)


Please note the addOption part was also not working in SP untill I did the below


UI Type=All


Script:


function onChange(control, oldValue, newValue, isLoading) {


    if (isLoading || newValue == '') {


          return;


    }


var a=g_form.getValue('country');


g_form.clearOptions('state');


alert(a);


    //Type appropriate comment here, and begin script below


    var gr=new GlideRecord('cmn_location');


gr.addQuery('country',a);


gr.query(function(gr) {      


  while(gr.next())    


  g_form.addOption('state', gr.state, gr.state);      


  });      


}