- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2015 05:50 AM
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!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2015 06:35 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2015 03:01 PM
Hi Blair,
If you set a variable using g_form.getValue before you clear the options and then use that variable in a g_form.setValue, you should be able to transfer the value held.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2015 05:50 AM
Travis,
Would I do this get/setValue in this same script? I tried doing it onSubmit, but didn't hold the value. Or, would I define a new field all together?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2015 06:15 AM
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var v = g_form.getValue('fieldname') + '';
g_form.clearOptions('role'); // Removes all options
var gr = new GlideRecord('u_privileged_support_roles');
gr.addQuery('u_platform', 'CONTAINS', newValue); // Setup the appropriate query here
gr.query();
while (gr.next()) {
var typeOptions = g_form.getControl('role');
var str = typeOptions.innerHTML;
if(str.indexOf(gr.u_role_category)==-1){
g_form.addOption('role', gr.sys_id, gr.u_role_category);
}
}
g_form.setValue('fieldname', v);
}
Bare in mind, you may need to clear any reference qualifiers and rely on the script to ensure that the selected value is accepted.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2015 07:01 AM
Travis,
That didn't work either.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2015 06:14 AM
Hi Blair
The lookup selectbox reference qualifier works only on load. It does not work on change of a field value. Use reference field instead of this.
Regards
Harsh