Assign INC based on less inc assigned to team member
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 07:27 PM
If user update "Assignment group" field and save, ServiceNow should automatically pick one member of the group with minimum incident ticket assigned and set the user in "assigned to" field
Please show step wise.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 09:06 PM
Hi @Pawan Kumar Rai ,
Please explore "Advanced Work Assignment" >> https://docs.servicenow.com/bundle/rome-servicenow-platform/page/administer/advanced-work-assignment...
If you try to achieve through custom logics and scripts , we may end up in many challenges
ex:
1)what if Many users has same number tickets assigned to them
2)Avaibility,Skills?? to attend the ticket
3)Maintenance of your logic??
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 01:34 PM
In Advanced work assignment there is no table field to specify on which table the rule should apply.
I'm using custom CSM application and looking for auto assign user with least cases assigned.
could you please assist
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 01:38 PM
"Advanced Work Assignment" does not have specify table on which it should apply.
Im using custom csm application . please assist on auto assign least assigned user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2023 11:20 AM - edited 08-26-2023 11:21 AM
Hi @Pawan Kumar Rai
If you are looking out for script, You can have before BR of your choice & code will be as below:
Condition: current.assignment_group.changes() && current.assignment_group.previous != current.assignment_group
Script in BR:
(function executeRule(current, previous /*null when async*/) {
var assignmentGroup = current.assignment_group;
var grMembers = new GlideAggregate('incident');
grMembers.addQuery('assignment_group', assignmentGroup);
grMembers.addAggregate('COUNT', 'assigned_to');
grMembers.groupBy('assigned_to');
grMembers.orderByAggregate('COUNT', 'assigned_to');
grMembers.query();
var membersWithMinLength = [];
var minCount = -1;
while (grMembers.next()) {
var count = grMembers.getAggregate('COUNT', 'assigned_to');
if (minCount === -1 || count < minCount) {
minCount = count;
membersWithMinLength = [grMembers.assigned_to.toString()];
} else if (count === minCount) {
membersWithMinLength.push(grMembers.assigned_to.toString());
} else {
break;
}
}
if (membersWithMinLength.length > 0) {
var randomIndex = Math.floor(Math.random() * membersWithMinLength.length);
current.assigned_to = membersWithMinLength[randomIndex];
}
})(current, previous);
Please mark as Accepted Solution & helpful if you get it 🙂