We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Servicenow developer

vodnalar26
Mega Contributor

Hi everyone,
I have created a custom table in ServiceNow, but it is not extended from the Task table.
In this table, I have a reference field to the User table (sys_user). My requirement is:
I want the User reference field to show only users who belong to a particular User Group.
The group members should be filtered so that only users in that specific group are visible/selectable.
Since my table is not extended from Task, I cannot use assignment group and assigned to functionality directly.
Could anyone please suggest the best approach to achieve this?
Specifically:
Should I use a Reference qualifier?
If yes, what would be the correct way to filter users based on group membership (sys_user_grmember)?
Is there any recommended best practice for this scenario?
Any guidance or example would be greatly appreciated.
Thanks in advance!

5 REPLIES 5

GlideFather
Tera Patron

Hi @vodnalar26,

 

yes, the reference qualifier is the best approach.

Go to the field on the custom table, click right mouse button on that field and select Dictionary, there you have the chance to add ref qualifier for a field with reference type.

_____
100 % GlideFather experience and 0 % generative AI

Dr Atul G- LNG
Tera Patron

Hi @vodnalar26 

I’m not sure about the use case. Since you didn’t extend the table from Task, this is a purely custom table and all the fields need to be created manually.

If you want to use User Group / User, a reference field is the best option here. As a rule of thumb, if the number of values in a dropdown is 10 or fewer, go with a choice field; otherwise, use a reference field.

*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************

SohamTipnis
Kilo Sage

Hi @vodnalar26,

 

Yes, as @GlideFather mentioned, you can use a reference qualifier; this will help you to add type with the table you want to have.

You can refer to the below image and documentation about the reference qualifier:

SohamTipnis_0-1771389152057.png

 

https://www.servicenow.com/docs/r/platform-administration/c_ReferenceQualifiers.html

 

If you find my answer useful, please mark it as Helpful and Correct. â€ŒðŸ˜Š


Regards,
Soham Tipnis
ServiceNow Developer ||  Technical Consultant
LinkedIn: www.linkedin.com/in/sohamtipnis10

yashkamde
Kilo Sage

Hello @vodnalar26 ,

 

The Best practice I would recommend to use advanced reference qualifier i.e,

ref qua -> 

javascript&colon; 'sys_idIN' + getGroupMembers('<grp_sys_id>');

 

And write the script Include to get group members filter out according to your requirement :

getGroupMembers: function(groupSysId) {
        var members = [];
        var gr = new GlideRecord('sys_user_grmember');
        gr.addQuery('group', groupSysId);
        gr.query();
        while (gr.next()) {
            members.push(gr.user.sys_id.toString());
        }
        return members;
    }

 

If my response helped mark as helpful and accept the solution.