We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Advanced Reference Qualifier on Record Producer

TCole94
Tera Expert

I am currently trying to create an advanced reference qualifier on record producer to have a dynamic user list show up when a certain record is referenced on the form.

 

When an event (record) is referenced on the form, each record contains a list of users. On an event record, there is a list type field (referenced to sys_user table) that contains users. (field name is u_poi)

 

The ask is only show the list of users for the referenced record on the form. 

 

Picture below:

ReferenceQualifier.png

For example:

1. If the event contains multiple users, the person of interest reference should only show the list of users on the event record.

 

I have tried creating a script include but no luck as of yet.

1 ACCEPTED SOLUTION

I figured out a solution. I created a script include and used the event record sysID as a parameter. Below is my script that worked:

 

getQuery: function(event) {

var gr = new GlideRecord("u_metric_example");
gr.get(event);

var users = gr.watch_list.toString().split(",");

var q = new GlideRecord("sys_user");
q.addQuery("sys_id", users);
q.query();

var filter = q.getEncodedQuery();

return filter;

},

View solution in original post

9 REPLIES 9

benn23
ServiceNow Employee

try replacing your semi-colon with a colon and it looks like you've got an '=' after the IN.   Try this 

 

benn23_0-1672946966548.png

 

I figured out a solution. I created a script include and used the event record sysID as a parameter. Below is my script that worked:

 

getQuery: function(event) {

var gr = new GlideRecord("u_metric_example");
gr.get(event);

var users = gr.watch_list.toString().split(",");

var q = new GlideRecord("sys_user");
q.addQuery("sys_id", users);
q.query();

var filter = q.getEncodedQuery();

return filter;

},

Here was my reference qualifier:

javascript:new MetricUtils().getQuery(current.variables.int_event);

benn23
ServiceNow Employee

Good deal.  FYI, the issue w/ your first approach is the equal sign after IN:

'sys_idIN='+current.variables.int_event.watch_list

It's prefixing that to the first string of the array.  Removing that would have worked as well.

TCole94,

Watch out for syntax errors...you have = signs all over the place.  There's one after sys_idIN on a previous post and before current.variables more recently...that one should be a comma.