Reference Qualifier

Mark Wood
Tera Contributor

Hello Experts,

I have created a custom table with two custom fields: Caller (referring to the sys_user table) and Group of Caller (referring to sys_user_grmember). In the advanced reference qualifier for the Group of Caller field, I have scripted "javascript:"user"+current.u_caller", but it is not restricting the data as intended. Can someone please provide guidance on how to achieve this?

Note that I prefer not to implement this requirement using a dependent field approach.

Thank you.

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

Hi Mark,

Almost there, you are missing an = after user:

BradBowman_0-1716913829132.png

 

View solution in original post

4 REPLIES 4

Brad Bowman
Kilo Patron
Kilo Patron

Hi Mark,

Almost there, you are missing an = after user:

BradBowman_0-1716913829132.png

 

Robbie
Kilo Patron
Kilo Patron

Hi @Mark Wood,

 

Is there a reason why you don't want to leverage the 'Dependent' field approach which essentially handles this for you? Simply click on the Dependent tab and select the group field the selectable callers should be filtered by.

 

To answer you question and putting the dependent approach aside, ServiceNow have an article with this info found below.

Here's the syntax you need: (Also take a look at the article assuming I've understood your question correctly)

 

javascript:'sys_idIN'+getIDs(current.group_field_name); function getIDs(grp){var m=GlideUserGroup.getMembers(grp);var ids=''; while (m.next()){ids+= (m.user+',');} return ids;}

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.
 
Thanks, Robbie

 

SN article:

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0831564

Sandeep Rajput
Tera Patron
Tera Patron

@Mark Wood I am assuming you need to show the Group based on the caller selected in the caller field. To implement this, instead of referring to sys_user_grmember table, you should refer to sys_user_group table and apply following reference qualifier in it.

 

Screenshot 2024-05-28 at 10.14.11 PM.png

Here is the reference qualifier.

getMyGroups(current.u_caller);function getMyGroups(user){ var glideGroupMember = new GlideRecord('sys_user_grmember'); glideGroupMember.addQuery('user',user); glideGroupMember.query(); var groupID=''; while(glideGroupMember.next()){ groupID = groupID+glideGroupMember.getValue('group')+','; } return 'sys_idIN'+groupID; }

Make sure to copy the qualifier as it is without any line breaks. Once this reference qualifier with group table is applied it will only return the groups based on the selected caller in the caller field.

 

Hope this helps.

Kiranmai_KVL
Kilo Sage

Hi Mark,

 

Here is the syntax to be used in the reference qualifier : javascript:'user='+current.u_caller;

 

Additionally if you see sys ID coming in the list view of the 'Group of caller' field, configure list layout & add group & user to the form layout as below & save after adding group & user field.. Hope this helps.

Screenshot 2024-05-28 at 5.45.06 PM.pngScreenshot 2024-05-28 at 5.45.16 PM.pngScreenshot 2024-05-28 at 5.45.41 PM.png