Automated assignment for incident

kenny_estrella
Tera Expert

Network Group manager wants to automate assigning tasks to members of the group. When a new incident is assigned to this group and it is not assigned to anyone, a configuration/script will assign it in a round robin assignment to the member. 

Note: Assign 10 members to the group.

For the SLA of the incident:

  1. Auto-Notifications should be sent out by the tool for:
    1. Tickets nearing SLA breach 70%.
    2. Tickets that breached the SLA 100%.
  1. Recipient of the notices should be the assigned support team.

Is it possible to get all group members number of assigned incidents or task, then the assigned to will be the group member with the smallest number of assigned task.

1 ACCEPTED SOLUTION

Hi Atulya, not sure what is Advance Work Assignment, I'm super new in ServiceNow, I just started studying June of this year.

View solution in original post

11 REPLIES 11

Hi @kenny_estrella 

 

Sorry , I am not a coder / pro 🙂 , but my recommendation to use modules instead of scripting.

 

Please accept my answer as solution or mark it helpful.

 

Regards

Atul G

 

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Dr Atul G- LNG
Tera Patron
Tera Patron

HI @kenny_estrella 

 

Greetings!!

Not sure, but did you try advance work Assignment.

 

Please mark this response as correct or helpful or the solution accepted if it assisted you with your question.

Regards
Atul G.
Learn N Grow With Atul G

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Hi Atulya, not sure what is Advance Work Assignment, I'm super new in ServiceNow, I just started studying June of this year.

Here is the script which checks the ticket count and assigns to member who has lowest ticket assigned.

Script:

var groupName = current.assignment_group;

// Get a list of members for this group
var members = [];
var gm = new GlideRecord('sys_user_grmember');
gm.addQuery('user.active', true);
gm.addQuery('group', groupName);
gm.orderBy('user');
gm.query();
while (gm.next()) {
members.push(String(gm.user));

}
// Get a list of their open ticket counts
var counts = [], agg, count;
for (var i = 0; i < members.length; i++) {
count = 0;
agg = new GlideAggregate('sn_sm_finance_task');
agg.addActiveQuery();
agg.addQuery('assignment_group', groupName);
agg.addQuery('assigned_to', members[i]);
agg.orderBy('assigned-to');
agg.addAggregate('COUNT');
agg.query();
if (agg.next())
count = agg.getAggregate('COUNT');
counts.push(count);
}
// find the minimum count and store its index
// we cannot use .sort().shift() or we won't know where to look in the members array
var min = counts[0];
var index = 0;
for (var j = 1; j < counts.length; j++) {
if (counts[j] < min) {
min = parseInt(counts[j]);
index = parseInt(j);
}
}
// get the member with the lowest count
var userID = members[index];
var h;
// Log their name to verify
var user = new GlideRecord('sys_user');
user.orderBy('name');
if (user.get(userID)) {
h = user.sys_id;
}
current.assigned_to = h;
current.update();

Regards
Harish

Hey Harish KM,

I'll test it out soon, the code you provided has given me an idea, thanks.