- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-22-2015 12:22 PM
Hello,
I am trying to populate a Lookup Select Box with the list of Mobile Phone #'s that is associated with a requested_for on an requested item form.
In the Past we have used the following Script Include called filterDevices on a reference qualifier line for a reference field.
function filterDevices() {
var answer = ' ';
var rf = current.variables.requested_for;
var usr = new GlideRecord('cmdb_ci_comm');
usr.addQuery('assigned_to',rf);
usr.query();
while (usr.next()) {
if (answer.length > 0) {
answer += (',' + usr.sys_id);
}
else {
answer = usr.sys_id;
}
}
return 'sys_idIN' + answer;
}
We have tried using this script include on the Lookup Select Box, but we do not get any results. We also tried variations of "assigned_to=current.variables.requested_for" and get 0 results. but when we tried "assigned_to=javascript:gs.getUserID()" it does return all mobile phones for the person logged in.
If anyone can point out if this is a syntax issue or if we are going about this incorrectly, it would much appreciated. Thanks
Solved! Go to Solution.
- Labels:
-
User Interface (UI)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-22-2015 09:03 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-23-2015 08:20 AM
Thanks for the response, I have tried what you suggested and it didn't seem to return anything.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-23-2015 08:45 AM
I would do some debugging: Is rf populated with something sensible?
Also: here's an easier way to build a comma separated list.
function filterDevices() {
var answer = [];
var rf = current.variables.requested_for;
var usr = new GlideRecord('cmdb_ci_comm');
usr.addQuery('assigned_to',rf);
usr.query();
while (usr.next()) {
answer.push(usr.sys_id);
}
return 'sys_idIN' + answer.join(',');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-23-2015 08:51 AM
rf is getting a reference field to the User table we have.
Our script include works for normal reference fields, where we use it as a reference qualifier. It just doesnt seem to work with Lookup Select Box. I will try the script include you have suggested to see if that fairs any better.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-23-2015 10:22 PM
As Pradeepprovided of a link to a thread. You also need to add attribute 'ref_qual_elements' in addition to reference qual.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2015 12:57 PM
Hey Gurpreet,
I reread the links that Pradeep provided and it made a lot more sense after mentioning ref_qual_elements.
The syntax that ended up working was:
Reference qual: javascript: 'assigned_to='+current.variables.requested_for;
Variable attributes: ref_qual_elements=requested_for
I read the Wiki page a handful of times and it wasnt apparent to me that this is what needed to happen.
Thanks for your suggestions.