- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2019 03:32 PM
Hi All,
I think I need to use a script include in reference qualifier field on the catalog variable of a lookup select box.
We don't have any catalog variables to date that have done that, so I'm not sure the syntax in the script include and the ref qualifier field to return the results below. It's almost like I need an if/then/else in the ref qualifier field but I know I cannot do that.
I have a catalog variable where the user will select an “Environment” which could be Prod, test, uat, sand, play, other.
I have another Lookup Select Box variable called “Size” that pulls from the “Size” table with 2 columns “Desc” and “Env”. I want to use a reference qualifier on this menu to…
Only return to the "Size" variable's menu the 2 “Desc” records where “Env=prod” if the Environment variable selected in the field above was “Prod” else return all 4 "Desc" into the "Size" variables's menu options.
Desc Env
Large prod
Medium prod
Small non-prod
Tiny non-prod
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2019 12:55 PM
Thanks for sharing the details. This was not working correctly because you had ref_qual_elements=u_description defined under variable attribute section whereas it should be ref_qual_elements=environment (environment is the reference variable name). I have updated it now and the lookup select box is now working fine as per your requirement.
-Pradeep Sharma

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2019 04:10 PM
Hi,
Below are the steps
1. Create the Script Include as follow
Name: getSize
Client Callable :True
Script: Update the line no 8 as per my comments
var getSize = Class.create();
getSize.prototype = {
initialize: function() {
},
getSize:function() {
var gp = ' ';
var en = current.variables.PASS ENVIRONMENT LOOK UP SELECT BOX VARIABLE COLUMN NAME HERE;
//return everything if the assigned_to value is empty
if(!en)
return;
var grp = new GlideRecord('PASS SIZE TABLE NAME HERE');
if(en =='prod')
{
grp.addQuery('PASS FIELD COLUMN NAME OF ENV FROM SIZE TABLE',en);
}
grp.query();
while(grp.next()) {
if (gp.length > 0) {
gp += (',' + grp.sys_id);
}
else {
gp = grp.sys_id;
}
}
// return Groups where assigned to is in those groups we use IN for lists
return 'sys_idIN' + gp;
},
type: 'getSize'
};
2. Navigate to the Lookup Select Box "size" and update the Lookup Value field to "SysID" and Lookup Label field with the exact field column name that you would like to display. Now set the reference qualifier as javascript:new getSize().getSize() and variable attribute field under section Default value to ref_qual_elements=PASS ENVIRONMENT FIELD COLUMN NAME HERE
-Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2019 05:07 AM
Thanks Pradeep. I appreciate the help. I hope the day comes when I can figure these out on my own. I'm going to work on this today. I'm grateful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2019 05:33 AM
Pradeep,
I have a question about line 10 in your example. What does !a refer to ?
if(!a)
This is frustrating.
The Size lookup select box field on the request form returns all records from the Size table regardless of which Environment I pick in the Environment lookup select box field.
The Size lookup should only return all sizes if the Environment selected is not Prod. If the Environment selected is Prod then the Size lookup variable should only display sizes where the field env in the size table is also "Prod".
I added some log statements and the 'en' var is being set to the sys_id of the value you pick in the Environment lookup select box.
Here's how the script include is looking so far:
var getSize = Class.create();
getSize.prototype = {
initialize: function() {
},
getSize:function() {
var gp = ' ';
var en = current.variables.environment;
gs.log(' var en is '+en);
//return everything if environment is not Prod
if(!a)
return;
var grp = new GlideRecord('u_fnf_azure_request_form_vm_tshirt_size');
if(en =='Prod')
{
grp.addQuery('u_environment',en);
}
grp.query();
while(grp.next()) {
if (gp.length > 0) {
gp += (',' + grp.sys_id);
}
else {
gp = grp.sys_id;
}
}
// return Sizes where assigned to is in those groups we use IN for lists
return 'sys_idIN' + gp;
},
type: 'getSize'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2019 09:03 AM
I will try this
var getSize = Class.create();
getSize.prototype = {
initialize: function() {
},
getSize:function() {
var gp = ' ';
var en = current.variables.environment;
gs.log(' var en is '+en);
//return everything if environment is not Prod
//if(!a)
//return;
var grp = new GlideRecord('u_fnf_azure_request_form_vm_tshirt_size');
if(en =='6dfc43451b03af000560a9bfbd4bcb55')
{
grp.addQuery('u_environment','Prod');
}
grp.query();
while(grp.next()) {
if (gp.length > 0) {
gp += (',' + grp.sys_id);
}
else {
gp = grp.sys_id;
}
}
// return Sizes where assigned to is in those groups we use IN for lists
return 'sys_idIN' + gp;
},
type: 'getSize'
};
This is a little better but now , no matter what I pick as the Environment the Size script include always returns Sizes where u_description = "Prod"
If Environment is not the sys_id for Prod then script include should return all Size records regardless of what u_description is.