Servicenow Scripting Question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
When an incident is assigned to a group it should be assigned to one person in that group, when the
second incident is assigned to same group it should be assigned to the second person and like this
the assignment should be cyclic for every member of that group.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
You can refer the below article for round robin assignment
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @DevarajK
Is this requirement for ALL assignment groups, or specific ones only?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @DevarajK ,
Yes, this is a classic round‑robin auto‑assignment requirement; it is not fully OOB but is easy to build with a Business Rule that rotates through the group members
Add filters on sys_user_grmember (e.g., only users with a custom u_auto_assign = true, or match a region/schedule) to control who participates.
If you prefer a “least loaded” approach instead of strict rotation, you can count each user’s open incidents and assign to the one with the fewest
Add a way to remember who got the last ticket for each group (either on the group record or in a separate table).
In a before insert Business Rule on Incident:
When assignment_group is set and assigned_to is empty, load all active users in that group.
Find the “next” user after the one who last received a ticket (or start at the first user if none).
Set current.assigned_to to that user and update the “last assigned” pointer.
Assumptions (adjust names to your design):
Table: Incident [incident]
BR: before insert (and optionally before update when assignment_group changes)
Custom field on group: u_last_assigned_user (reference to sys_user)
(function executeRule(current, previous /*null when async*/) {
// Only when group is set and no assignee yet
if (!current.assignment_group || current.assigned_to) {
return;
}
var groupId = current.assignment_group;
// Get active members of this group
var members = [];
var grMem = new GlideRecord('sys_user_grmember');
grMem.addQuery('group', groupId);
grMem.addQuery('user.active', true);
grMem.query();
while (grMem.next()) {
members.push(grMem.user.sys_id.toString());
}
if (members.length == 0)
return; // no one to assign
// Read last assigned user from the group
var grGroup = groupId.getRefRecord();
var lastUser = grGroup.u_last_assigned_user.toString();
var nextUser;
if (!lastUser) {
// First time: start with first member
nextUser = members[0];
} else {
var idx = members.indexOf(lastUser);
if (idx == -1) {
// last user no longer in group, start at first
nextUser = members[0];
} else {
// round‑robin: move to next index, wrap around with %
var nextIdx = (idx + 1) % members.length;
nextUser = members[nextIdx];
}
}
current.assigned_to = nextUser;
// Persist who was last assigned for this group
grGroup.u_last_assigned_user = nextUser;
grGroup.update();
})(current, previous);This gives exactly what you described:
1st incident to member 1, 2nd to member 2, …, Nth to member N, then back to member 1, per group
You may find below thread helpful:
- https://www.servicenow.com/community/developer-forum/round-robin-assignment-using-business-rule/m-p/...
- https://www.servicenow.com/community/itsm-forum/assign-the-incident-between-5-members-in-one-groups-...
- https://www.servicenow.com/community/developer-forum/round-robin-auto-assignment-of-new-incidents-an...
If it is helpful, please hit the thumbs button please mark the answer as correct based on the impact!!
Kind Regards,
Shaik Mohammed Mustaq