Default Assignment Group

ljschwaberow
Giga Expert

We have several groups, that we use for workflows and change request forms, in our ServiceNow instance that have the same users and we are wanting to have a default group set up for each user. That way when they fill out change request forms or are filling out an incident a specific group will always populate the same group. I have added a 'Default Group' true/false field to the list under each group and have set those individuals to true. However, I am assuming I would need to set a default value for the assignment_group field on the task table to pull the group with default group = true. However, I'm not quite sure what needs to be entered.

find_real_file.png

18 REPLIES 18

brad_hicks
Giga Expert

This script would assume that you have a field created on the user table called u_default_group which would house the default group for each user.   The first thing you would do is create a global script include called "getMyDefaultGroup" and replace the script section with the following script:


function getMyDefaultGroup() {


    var defaultGroup = '';


    var userGR = new GlideRecord('sys_user');


    if(userGR.get(gs.getUserID())) {


          defaultGroup = userGR.u_default_group.toString();


    }


    return defaultGroup;


}


Then on the appropriate assignment group field you would set the default value to javascript:getMyDefaultGroup()


Or, if it's workflow driven, just assign it to the field variable:


for the RITM: current.assignment_group = current.request.requested_for.u_default_group;


for the TASK: task.assignment_group = current.request.requested_for.u_default_group;


or have the whatever.assignment_group = current.opened_by.u_default_group;


This seems like it will work for what I am wanting to accomplish. However, I am a little confused as to where this global script goes? Does this go under Client Scripts, UI Scripts....etc?


You would create a Script Include and call it "getMyDefaultGroup".   It will auto-populate information in the script section.   Remove all of the auto-populated information and replace it with the script.


This has worked great for me, thanks Brad. However I am now wondering if there is an easy way to bulk update users' Default Groups?



For example in the Group members tab when in a Group I would like to be able to add 'Default Group' as a column and then bulk update all group member's Default Group to the same value. Is this at all possible? At the moment I am only seeing a handful of fields available when clicking on the cogwheel to Personalize List Columns. Alternatively to somehow be able to sort the Users list by Assignment groups (again not currently a selectable column from what I can see) and bulk update would do the trick also.



Many thanks in advance,
Daniel