
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 05-23-2021 09:25 AM
Reference Qualifiers
1.0 Reference Qualifier:-
Reference Qualifiers are to create filters that restrict the data that is returned for a reference field. A reference field stores a link (reference) to a field on another table, making the records/fields in the referenced table available to the form containing the reference field. Reference qualifiers are a powerful tool that every Service Now administrator and consultant should have in their tool belt. They allow you to dynamically filter the available options from a reference field.
Example :- Caller, Assigned To field on Incident Table which refers to User [sys_user] table.
Reference Qualifier in ServiceNow
2.0 Types of Reference Qualifiers:-
- 1) Simple 2) Dynamic 3) Advanced
2.1 How to Reach Reference Qualifier in OOB Table or Custom Table : - Open any Table of Your Choice: - Incident/Problem/Change.
- Step 1:-Application Navigator>Incident>Open Existing Record or Create New.
- Step 2:-Right Click on Any Reference Field i. e. Caller
- Step 3:-Configure Dictionary.
- 2.1 How to Reach Reference Qualifier in Service Catalog : - Open any Catalog Item from main item (sc_cat_item) Table
- Step 1 :- Open any your catalog item
- Step 2 :- Go to Related List and Open your Variables Tab
- Step 3 :- Open any Reference Type Variable
- Step 4 :- Check in Type Specification
3.0 Simple Reference Qualifiers: - Simple reference qualifiers use AND/OR statements (conditions) to create simple filters. Use simple reference qualifiers when filtering on conditions such as whether a company is active, a user has a specific role, and/or a caller is in a specific time zone. Simple reference qualifiers can have a maximum of 13 reference qualifier conditions.
3.1 Please Check below:-
4.0 Dynamic Reference Qualifier:-Dynamic reference qualifiers enable you to use a dynamic filter option to run a query against a reference field to filter the returned data set. Dynamic filter options are stored filters that can contain encoded query strings, JavaScript, or script includes, and can be used in multiple dynamic reference qualifiers. Changes made to a dynamic filter option automatically apply to all reference qualifiers that use the same dynamic filter option. Use this type of reference qualifier when you want to use the same filter on multiple forms or to provide filter functionality to "non-code savvy" implementers. The base instance provides several OOB dynamic filter options. If a dynamic filter option that meets your needs does not exist, you can create a new dynamic filter option that is specific to your requirements.
All the available dynamic filters are stored in system definition>dynamic filter options.
For creating the dynamic reference qualifier we must have a record in this dynamic filter options.
After creating the dynamic reference qualifier you can add that filter from the Dynamic ref qual field.
It is Best Practice to add Script Include instead of Global Business Rule in Reference Qualifiers.
5.0 Advanced Reference Qualifier: - Advanced reference qualifiers enable you to define an inline encrypted query string or JavaScript (actual code or the name of an existing script include or business rule) filter directly in the Reference qualified field of the reference qualifier. Similar to the other reference qualifier types, when the form loads, the filter is executed, and only the records that match the filter appear in the reference field. Use this type of reference qualifier for implementations that only require a simple, unique filter that cannot be handled by a simple reference qualifier, and is not used across multiple reference fields.
In the reference qualifier we have lots of techniques to add filter:-
We can directly addQuery here like active=ture
One more way is to add JavaScript filters such as javascript: 'u_active=true^' + "u_hr_service="+current.hr_service in reference qualifiers.
We can call server side script include in advance reference qualifier:- syntax is
javascript: <script>(). <function name>()
The function must return a query string that can filter the options available on a reference field.
Please Follow the Syntax below:-
This is How we have we have seen the Journey so far about the Reference Qualifier.
Now below I will adding the some scenarios which I came across during my profession career.
also I will be adding some links which might be helpful for all of you to explore this topic more.
Use of INSTANCEOF in Reference Qualifier:-
6.0 Use of INSTANCEOF operator in a reference qualifier:-
we can use the INSTANCEOF operator in a reference qualifier to shorten or simplify a complex class qualifier.
7.0 Scenario :-
Scenario 1:-
We need all the Active users in Caller Field and all users must belong to IT Team only.(use Simple)
Just add simple qualifier and use condition builder to filter these 2 fields.
Scenario 2:-
I want the VIP user available in Caller Field of Incident Table:-
You can use the Simple Variable with just add the Condition builder.
Scenario 3:-
When we click on Caller Field, we must get reflected as per current logged in user. If user belongs to IT Team then user from IT Team Must gets displayed when we click on look up Icon.
department:function()
{
var gr=new GlideRecord('sys_user');
gr.addQuery('sys_id',gs.getUserID()); gr.query();
if(gr.next())
{
return "department"+"="+gr.department.toString();
}
},
Scenario 4 :-
Set a person who belongs to the same department as the applicant's department.
getDepartmentUsers: function() {
var userRec = new GlideRecord('sys_user');
userRec.get(gs.getUserID());
var department = userRec.getValue('department');
var usersList = [];
var grUser = new GlideRecord('sys_user');
grUser.addQuery('company', gs.getUser().getCompanyID());
grUser.addQuery('department', department);
grUser.query();
while(grUser.next()) {
usersList.push(grUser.getUniqueValue());
}
return 'sys_idIN' + usersList;
},
Scenario 5 :-
I have a couple of Reference Fields. If I click on the look up icon I want the data to be populated depending on some filters or query..and every user can see data depending on his category.
department:function()
{
var gr=new GlideRecord('sys_user');
gr.addQuery('sys_id',gs.getUserID());
gr.query();
if(gr.next()){
return "department"+"="+gr.department.toString(); }
},
Scenario 6 :-
Requirement to filter user in field Creator (Reference to sys_user), dependent group user login.
createGroup :function()
var grpcr;
var usr=gs.getUserID();//get current logged in user Id
var usrarr=[];
var groupss=new GlideRecord('sys_user_grmember');
groupss.addQuery('user',usr);
groupss.query();
while(groupss.next())
{
grpcr=groupss.group;
}
Scenario 7 :-
select the Manager in 1 reference field, and his Manager (selected manager's) needed to be shown in other Reference Field.
var var sys_id="";
var gr=addNotNullQuery('manager');
gr.query();
while(gr.next())
{
sysid=sysid+", "+gr.manager;
}
return ' sys_idIN'+sysid;
Scenario 8 :-
select the Manager in 1 reference field, and his (selected manager's) related members only needed to be shown in other Reference Field.
var var sys_id="";
var gr=addNotNullQuery('manager',manager);
gr.query();
while(gr.next())
{
sysid=sysid+", "+gr.manager;
}
return 'sys_idIN'+sysid;
Scenario 9 :-
The User wants to have Assignments Group Visible:-
Use below Reference Qualifiers
function getCaseGroups() {
var groupNames = "Accounts Receivable _ JIB, Revenue, Division Order, Payables, Regulatory, Production Reporting, Lease and Contracts Information, Land and Operations, SCOR Customer Care Center";
return groupNames;
}
8.0 Some Important Notes and Best Practices about Reference Qualifier:-
- If You have added Reference Qualifier on variable set then it will not work on the variables outside the Variable Set or Vice Versa with Variables.
- Reference Qualifiers are only Applicable to Reference Fields or Reference Variables
- It is Best Practice to add Script Include instead of Global Business Rule in Reference Qualifiers.
9.0 Some Important Links of ServiceNow Community Experts :-
10.0 Videos to kick start this Topic:-
Video 2
Link of my Another Article:-
Uses of hasRole() Methods (client and server side)
Please Mark Helpful to the Article , share it amongst all your colleague
Thanks and Regards
Gaurav Shirsat
- 64,980 Views

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Thank You

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Nice One Gaurav 🙂
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
well explained. Great help through this article 🙂

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Thanks a lot Pranav
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
useful information...thank you
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Thank yo
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Helpful..
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Thanks Gaurav, I love it
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
very informative and helpful
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
very helpful
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Thanks for this support..This is really helpful 👍

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Nice Explained, really useful content.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Really Helpful

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Thank you, very very useful !

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Nice! Once place for all related stuff.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Really Helpful
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
well explained.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Very well explained.

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
A greatly detailed article, Gaurav!
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
very Helpfull
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Thankyou @Gaurav Shirsat Greatful to see the content like this.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Thank you for this! Wonderfully explained. Also, can you let me know where can I find these type of real-time scenarios to understand Client Scripts, BRs etc?

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hello @Lavanya R1
First Things First, Your PDI is your good Tutor. Open your PDI you will find many Business Rules, Client Scripts, Script Includes Out of the Box.
Go through them, analyze them and learn.
post that each day, there are thousands of question of community and new UI of Community helps you to filter things. try those use cases.
You can reach out to me in case you need any help.
Gaurav Shirsat : ServiceNow Community MVP 2022
https://www.linkedin.com/in/gauravshirsat/
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
@Gaurav Shirsat Thank you, the content was very helpful
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Thank you for this
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Thanks, @Gaurav Shirsat for the amazing example given.
Can I check if I can have an ITIL role condition adding to the simple script below.
my input is taken from requested_for, from there I would determine if the user has an ITIL role, if yes RETURN the full list else return only the group that they are below to.

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi @Tungw ,
Just give a test you are getting accurate results after applying this condition in your requested for/reference variable or not ? it should work actually, but make sure you are collecting logged in user from server code and then doing .walk for his role check
else create an Script Include and call them here,
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Thank you for sharing... really helpful @Gaurav Shirsat 👍