Populate Assignment Group & Assigned To based on the logged in user and their Primary Group

RichardSaunders
Tera Guru

I need to be able to populate the Populate Assignment Group & Assigned To for service desk staff only. This should not happen to users using the self service portal.

I have experimented with default value: javascript:gs.getUserID() and assignment rules but can not get it working.

any advise/pointers?

1 ACCEPTED SOLUTION

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);


}


}


}


View solution in original post

20 REPLIES 20

hannahwalter
Giga Contributor

When we moved from Cherwell to ServiceNow, keeping familiar team names made the transition easier for our service desk. Renaming would have caused confusion, so we stuck with Department-Support Team names like COMM-Integrated Media for smooth ticket management. Finding the best writing essay services also requires choosing what works best to ensure efficiency and reliability.