Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

How to Use Reference Qualifier for a Lookup Select Box

chris_choi
Giga Contributor

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

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
9 REPLIES 9

Pradeep Sharma
ServiceNow Employee

Hi Chris,



You may find the below thread helpful.


https://community.servicenow.com/thread/188762


Thank you for the response, I have seen those threads and still wasn't able to understand where we are messing up.



On the Variable Type Wiki Page it, provides an example of:


  • Reference qual:caller_id=javascript:gs.getUserID()^active=true

Which is how we came to try assigned_to=current.variables.requested_for, which doesnt work for what i assume is syntax issues.


Thanks Pradeep, looks like the answer was in there I just didnt understand it at the time.


Gurpreet07
Mega Sage

Try following


javascript:'assigned_to='+current.requested_for