If a user is member of more than one assignment group, how can we make one assignment group as his default assignment group?

benz2016
Kilo Explorer

If a user is member of more than one assignment group, how can we make one assignment group as his default assignment group?

I have Service Desk Analysts who are a member of 2 assignment groups - Group A and Group B

The Default assignment group for all tickets is Group A but when some analysts click on "Assign To Me", it changes the assignment group to Group B

It does not happen when the select their name manually in "Assigned to me" field and Click "Save"

4 REPLIES 4

ghsrikanth
Tera Guru

I dont know any property which can say that this particular group is default for a user.


May be introduce a new attribute like 'defaultGroup' (boolean) in sys_user_group, the table which has information of users and their groups and for every user mark one group as default like a flag which says true or false.


And the above requirement can be achieved by onChange script, by querying the sys_user_group table and retrieve the group which default flag = true for that user



Mark if it is helpful


HugoFirst
Kilo Sage

I'm with Srikanth,   I don't know of a way out-of-the-box to do this.



If I were to approach the problem, I'd do something like this:


1. Create a new field on the sys_user table named u_default_group which would be a reference variable to the sys_user_group table.


2. Populate this field any of a number of ways ( here are 2 )


        - Expose it on the "Self Service" view of sys_user and ask all the users to set it for themselves.


        - Have a scheduled job run to set the u_default_group to the first group returned on a query of groups for this user.


3. Change the "Assign To Me" UI Action to refer to u_default_group to make the assignment.


Brian Dailey1
Kilo Sage

Hi benz,



We have gone the route mentioned by others here, of adding a custom "Default Group" field to [sys_user].   The problem with this approach is remembering to fill in this value in addition to setting up the user's group memberships.



What I would recommend is instead adding a custom "Default" field to the many-to-many table "Group Member" [sys_user_grmember] that stores the users group membership.   This shows as a related list on the user's record, and you could easily just set this Default field to true while maintaining the group memberships.



The only additional piece you would need is a Business Rule (make as an After business rule on [sys_user_grmember] for Insert/Update) to make sure a user has only one group membership marked as default (assumes your custom field is named 'u_default'):



var grGroups = new GlideRecord('sys_user_grmember');


grGroups.addQuery('u_default=true^user=' + current.user.sys_id + '^group!=' + current.group.sys_id);


grGroups.query();


while(grGroups.next()){


        grGroups.u_default = false;


        grGroups.update();


}




See if that works for you.




-Brian


sgrison
Tera Guru

If a user is a member of multiple groups then let them select the group in which the record applies to (incident, problem, change, etc).



Having a 'default assignment group' on the user record will be a challenge to maintain and probably won't bring much value.   Your are opening yourself up to a world of hurt!



If you'd like to keep the button I would have it do the following:



  • if the user is a member of 1 group then set the assignment group and assigned_to
  • If the user is a member of multiple groups then clear the assignment group and set the assigned_to