How to populate Primary Assignment Group of a logged in user in Assignment Group on a Incident form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2023 10:30 PM
Hi all,
I have a requirement where I have to auto populate a Assigned To and Assignment Group field on Incident form with logged in user and his/her Primary Assignment Group.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2023 10:41 PM
Hi @Sid_Takali ,
You can write an onLoad Client script + Display BR to achieve this.
In Display BR
g_scratchpad.userObj = gs.getUser();
g_scratchpad.priGrp = gs.getUser().u_primary_assignee_group; // If you have the assignment group field
In Client Script
g_form.setValue("assigned_to",g_scratchpad.userObj);
g_form.setValue("assignment_group",g_scratchpad.priGrp);
Please mark correct if my response has solved your query.
Cheers,
Mohammed Basheer Ahmed.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2023 11:07 PM
Hi @Sid_Takali ,
As you are doing it on client level prefer not to use GlideRecord object or getReference object, Instead go for Display BR as mentioned or go for GlideAjax using Script Include. You may get the values from GlideRecord or getReference but they will impact the load time of the form.
Please mark correct if my response has solved your query.
Cheers,
Mohammed Basheer Ahmed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2023 10:49 PM
@Sid_Takali Hi!
Is this what you are looking for with an onLoad client script?
function onLoad() {
//Type appropriate comment here, and begin script below
var grp = g_form.getValue('assignment_group');
if (grp == ''){
var userName = g_user.userName;//logged in user
var gr = new GlideRecord("sys_user");//check if the logged in user has a primary group
gr.addQuery('user_name', userName);
gr.addQuery('u_primary_group', '!=', '');
gr.query();
if (gr.next()){//logged in user is a member of assignment group
g_form.setValue('assignment_group', gr.u_primary_group);
g_form.setValue('assigned_to', g_user.userID);
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2023 10:49 PM
And if you want to restrict this to users with a specific primary group, you could change this line:
gr.addQuery('u_primary_group', '!=', '');
to this:
gr.addQuery('u_primary_group', '<specific group's sys_id>');
Please mark my answer helpful of it helps...