Change the assignment group to the group the fulfiller is a member of when changing the state of an incident to Resolved

heidiyablonski
Tera Contributor

Hello Community,

I have a request to change the assignment group to the assignment group of the fulfiller when they are changing the status of an incident to Resolved. What would be best way to accomplish this? I have a rule to change hte assigned to field to the person who is resolving the incident but I am struggling with what the  property would be for the assignment group a user belongs to.

 

This is my simple business rule  script for   changing the assed to person:

(function executeRule(current, previous /*null when async*/) {

 // Add your code here
 current.assigned_to = gs.getUserID();

})(current, previous);

 

I dont want the UserID but I dont know what the property would be for the assignment group a user is a member of.

8 REPLIES 8

Tim Deniston
Mega Sage
Mega Sage

This is not easy since a user can be in multiple groups, whether they are assignment groups or approval groups, etc. How would you pick the right one?



I have seen fields added to the user table called "default assignment group" or "primary assignment group" but that seems like a nightmare to maintain.


siva_dirisala
ServiceNow Employee
ServiceNow Employee

There is a server side api, gs.getUser().getMyGroups() that can be used to see if the user belongs to a single group and then assign.


ajbarnes
Tera Expert

Hi Heidi,


Typically users are and can be in multiple groups. You can do something like - on the user record set a "default" workgroup on a per user basis. Then with that field available you can populate the assignment group from the users default group field.


Then in your business rule you can do:


current.assignment_group = gs.getUser().get('customdefaultassignmentgroupfield);



If you can be sure they are only in one group - you can use


current.assignment_group = gs.getUser().getMyGroups();


Bharath Padaki
ServiceNow Employee
ServiceNow Employee

Hi Heidi,



There isn't a property to do this, but you retrieve a list of groups that a user is a member of. However, the challenge here would be to determine which group should be picked from the list to be assigned to the Incident. There are ways to accomplish this by setting a default assignment group for the user, but this ends up in a data maintenance nightmare.



Another approach is to force the user to pick the assignment group when resolving an incident, but again, you end up forcing 2-3 clicks to accomplish what should be a smooth process. I would rethink the approach.



The system does maintain information about who marked the Incident resolved in the "Resolved By" field, if that helps.