Please use below steps to implement Round Robin Assignment Rule
1. Add two custom fields to sys_user
- u_last_assigned_task (reference to Task)
- u_last_assigned_task_date (datetime)
When you add these fields, be sure to set the no_audit attribute to true.
2. Create an After Insert/Update Business Rule on the Task table. This rule will update sys_user to track the last time a task was assigned to a user. Because this is an "after" Business Rule, it will run after the assignment rules engine and any "before" rules. Use these conditions
- Assigned to changes
- Assigned to is not empty
The code is
var getUser= current.assigned_to.getRefRecord(); getUser.u_last_assigned_task = current.sys_id; getUser.u_last_assigned_task_date = new GlideDateTime(); getUser.update();
3. Add a custom field field to sys_user_group
- u_round_robin_group (reference to sys_user_group)
If u_round_robin_group is empty, then this group is not participating in round-robin. If you want the group to round-robin through all members of the group, then set Round Robin Group to itself. If you want the group to round-robin through a subset of the group members, then create a special group whose only purpose is to hold the group members who participate in the round-robin. In other words, the group "XXX Round Robin" contains the members of "XXX" who are participating in the Round Robin. In our case the Round Robin Group would exclude the manager and anyone on vacation.
4. Create a Before Insert/Update Business rule on the Task table to do the actual Round Robin assignment. Note the "orderBy" in the code below, which is the key to making Round Robin work. This rule should have an order number greater than 1000 because it should run after the assignment rules engine as described here:
This Business Rule should run on these conditions
- Assignment group changes
- Assignment group is not empty
- Assignment group.Round Robin Group is not empty
- Assigned to is empty
The code is
var gMember = new GlideRecord('sys_user_grmember'); gMember.addQuery('group', current.assignment_group.u_round_robin_group); gMember.orderBy('user.u_last_assigned_task_date'); gMember.query(); if (gMember.next()) { current.assigned_to = gMember.user; }