Skip to main content

ServiceNow Reference Qualifier with real time scenario

Let's understand about ServiceNow Reference Qualifier which is quite important topic and an be used to filter the data on reference field. 

What is Reference Qualifier ?

Use reference qualifiers to create filters that restrict the data that is returned for a reference field.

What are types of Reference Qualifier ?

1.> Simple

2.> Dynamic

3.> Advanced

1.> What is Simple Reference qualifier ?

Simple reference qualifiers use AND/OR statements (conditions) to create simple filters.

 Ex - 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.

2.> What is 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. 

Ex- you can add dynamic filter created. In dynamic filter, you can call script include as per your requirement.

Let's implement a real time scenario of Dynamic Reference Qualifier :

Let's show only members who are part of the assignment group in user field for Catalog Item(having two fields assignment group & user) shown below :

Step 1- Navigate to sys_filter_option_dynamic table -

Create new Dynamic filter option with named "GroupMembers"


Step 2 - Call Script Include "GroupMembers" & function "getGrpMembers" in Script field defined below :

Script Include : GroupMembers

var GroupMembers = Class.create(); GroupMembers.prototype = { initialize: function() { }, 

getGrpMembers: function() { 

var GrpU = current.variables.assignment_group_name.sys_id; 

var grpMember = new GlideRecord('sys_user_grmember'); 

grpMember.addQuery('group',GrpU ); 

grpMember.query(); 

var userMember= ''; 

while (grpMember.next()) { 

userMember+= ',' +grpMember.user.sys_id;  }

return 'sys_idIN' +userMember; 

}, type: 'GroupMembers' };

Now, Select Dynamic Reference Qualifier option in Type specification of user field dictionary & add the dynamic filter "GroupMembers" which we have created, image shown below for your reference :

Refer the Reference Qualifier videos on ServiceNow Adda YouTube channel for better understanding link below:

Reference Qualifier Video

Advanced Reference Qualifier

Hope you like my blog, let me know in comment section below ! Stay tuned for new blog.



Comments

Popular posts from this blog

Difference b/w After & Async Business Rule in ServiceNow

Let's try to understand difference b/w  After & Async Business Rule & some examples on Real time scenario of After Business Rule & Async Business Rule : 1.> After BR executes synchronously (It will wait for a result, once result is ready & get displayed then user will get control to do anything, user has to wait) but Async BR executes asynchronously (user will get control immediately, it will not halt the user and result will get displayed when its ready or get response from system, it will be executing in the background as per system scheduler). 2.>After BR is used to update information on related objects that need to be displayed immediately such as GlideRecord queries etc. whereas Async BR is used to update the information on related objects that do not need to be displayed immediately such as calculating metrics & SLA etc. 3.>We can use current & previous objects but We can’t use previous object in Async rule & current ob...

How to use getreference() with callback function in client Script | #ServiceNow

What is the use of getReference() ? getReference() gets the record used in another reference field. For example you have the requested_for (reference to the sys_user table) and with getReference, you will retrieve the User record and save this as a gliderecord into a variable. Why we use callback function with getReference?  callback function allow you to use asynchronous processing with your getReference call. Example: FetchCompany&phoneNo function onChange(control, oldValue, newValue, isLoading) {    if (isLoading || newValue == '') {       return;    }  var requester_user = g_form.getReference('requested_for', callback); function callback(requester_user) { g_form.setValue('email_id',requester_user.email); g_form.setValue('manager', requester_user.manager); } }

ServiceNow Interview Questions - real time

Let's see some ServiceNow Scenario based Interview Questions & Answers here, 1.> How to fetch latest 10 incident records ? var grIncident = new GlideRecord('incident');  gr.orderByDesc('sys_created_on');  gr.setLimit(10);  gr.query();  while (gr.next()) {  gs.print('check the :'+ grIncident.number);   } 2.>How can you populate caller_id in short Description on Problem form? Write Onchange client script on Problem table on change of caller Id field  var caller =g_form.getValue(‘caller_id’);  g_form.setValue(‘short_description’, caller); 3.>How to send notification to the user who is member of assigned group? You can write the below code in Advanced condition of Notification gs.getUser().isMemberOf(current.assignment_group); 4.> How can you populate the only users whose department is “Finance” in caller field on Incident form. Use Simple Reference Qualifier & select “department is “Finance”. You can write the code ...