The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Gaurav Shirsat
Mega Sage

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.

find_real_file.png

find_real_file.png

find_real_file.png

  • 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

find_real_file.png

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:-

find_real_file.png

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.

find_real_file.png

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

find_real_file.png

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:-

find_real_file.png

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.

Use of INSTANCEOF Operator

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 :-

Refer 1

Refer 2

Refer 3

Refer 4

10.0 Videos to kick start this Topic:- 

Chuck Tomasi

Video 1

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

Comments
sekhar kurumoj1
Kilo Expert
Thank you great explanation
Gaurav Shirsat
Mega Sage

Thank You

Pranav Bhagat
Administrator
Administrator

Nice One Gaurav 🙂

anjali_sinha1
Kilo Explorer

well explained. Great help through this article 🙂

Gaurav Shirsat
Mega Sage

Thanks a lot Pranav @Pranav Bhagat 

venkatesh10
Giga Contributor

useful information...thank you

Susmitha8
Mega Explorer

Thank yo

pallavi bhosal1
Tera Contributor

Helpful..

Renuka7
Giga Explorer
Helpfull...
ServiceNow Use6
Tera Guru

Thanks Gaurav, I love it

srilakshmikanth
Tera Contributor

very informative and helpful

Aditya1204
Tera Contributor

very helpful

Hslk
Kilo Contributor
Mosthelpful
Pramod KInge1
Giga Contributor

Thanks for this support..This is really helpful đź‘Ť

Chetan Mahajan
Kilo Sage
Kilo Sage

Nice Explained, really useful content.

Neha Tiwari1
Kilo Contributor

Really Helpful

Jean-Emmanuel 1
Tera Contributor

Thank you, very very useful !

Anil Lande
Kilo Patron
Kilo Patron

Nice! Once place for all related stuff.

Sohail Khilji
Tera Sage
Tera Sage

Really Helpful

Nishchal
Tera Explorer
Thanks, very nice explanation. very helpful.
Rohit Raj
Tera Contributor

well explained.

Shikha Thakur2
Tera Explorer

Very well explained.

Harneet Sital
Tera Guru
Tera Guru

A greatly detailed article, Gaurav! 

Renuka7
Giga Explorer
Very helpful, Thanks Gaurav
Surbhi12
Tera Contributor
Thank you for sharing... really helpful.
sak3
Mega Contributor
thanks 
Gaurav Shirsat
 
very usefull article 

 

Ashwini K
Tera Explorer

very Helpfull 

Nani nanee
Tera Contributor

Thankyou @Gaurav Shirsat  Greatful to see the content like this.

Lavanya R1
Tera Contributor

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?

Gaurav Shirsat
Mega Sage

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/

ServiceNerd
Tera Contributor

Shaury
Tera Explorer

@Gaurav Shirsat  Thank you, the content was very helpful

Sujit Jadhav
Mega Guru

Thank you for this

 

Version history
Last update:
‎05-23-2021 09:25 AM
Updated by: