- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2017 02:42 AM
Hello,
By Referencing Round-Robin (Auto Assignment of new incidents and tasks) , I am assigning tickets automatically, But All tickets are assigning to single person. can anyone make changes, so that, Assign to all persons and in Round-Robin Procedure.
Thanks,
NItesh
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2017 03:19 AM
Hi Nitesh,
Create On-After business rule and apply this code
(function executeRule(current, previous /*null when async*/) {
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.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('incident');
agg.addActiveQuery();
agg.addQuery('assignment_group', groupName);
agg.addQuery('assigned_to', members[i]);
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');
if (user.get(userID)) {
gs.log('Name: ' + user.sys_id);
h = user.sys_id;
}
current.assigned_to = h;
current.update();
})(current, previous);
Thanks and hope this is helpful
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2017 03:19 AM
Hi Nitesh,
Create On-After business rule and apply this code
(function executeRule(current, previous /*null when async*/) {
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.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('incident');
agg.addActiveQuery();
agg.addQuery('assignment_group', groupName);
agg.addQuery('assigned_to', members[i]);
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');
if (user.get(userID)) {
gs.log('Name: ' + user.sys_id);
h = user.sys_id;
}
current.assigned_to = h;
current.update();
})(current, previous);
Thanks and hope this is helpful
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2017 06:47 AM
Hello Harish,
Thanks for your response. Code is working, but its again assigning to single user. Can you plz through some light and elaborate me little bit deep. You can modify my code or code gave by you and help me out. so that to assign tickets to all users in group in round-robin fashion.
Thanks,
Nitesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2017 09:12 PM
Hii Harish,
Thanks for Your suggestions. Its working Fine with Incident Table, But If I created any user defined table and working on it, All tickets are again assigning to single user. Is it possible to do it in user defined table.
Thanks,
Nitesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2021 12:31 AM
Hi harishdasari,
It's working fine thanks, i need to assign the ticket based on caller languge and least ticket count in the group member.any idea?