Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Auto populate Assignment group of logged in user

Appu
Tera Guru

Hi ,

I want the Assignment group to show logged-in users groups currently I have a script that shows selected users group

find_real_file.png

what modifications to be done to the script and what should be the reference qualifier.

Kindly help me

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

please update this query

grAssigneeGroups.addQuery('user', gs.getUserID());

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

please update this query

grAssigneeGroups.addQuery('user', gs.getUserID());

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Michael Jones -
Giga Sage

Sorry - I think I mis-read the idea. Ankur's approach is the right way to go.

Do all of your users have only one assignment group (a single group they are a member of) or do they have multiple groups that they belong to? You would need to determine how you would identify the assignment group in a situation where multiple might be available, otherwise you will just end up with an array of all of the groups the user is a member of. 

So you would need to adjust your grAssigneeGroups.addQuery() as advised above ('user', gs.getUserID()); but also add some additional criteria using grAssigneeGroups.addQuery() to limit your results to the one group you want. 

In the past, I've seen companies add a group reference field to the sys_user record and call it "Primary Assignee Group" and set the group on the user record. If you did this, you could get the group with a simple call like this:

user = new GlideRecord('sys_user');
user.get(gs.getUserID());
group = user.u_primary_assignee_group

I hope this helps!

If this was helpful or correct, please be kind and remember to click appropriately!

Michael Jones - Proud member of the CloudPires team!

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!