How To Randomly Auto Assign Tasks in ServiceNow

Auto Assign Capabilities – What is Out Of Box? By default, when any record is assigned to a group, there’s no automatic behavior to update the “Assigned to” user. There is no round robin or …

Newsletter Signup

Want to get better at ServiceNow?
(One email per month)

auto assignment round robin in servicenow

Auto Assign Capabilities – What is Out Of Box?

By default, when any record is assigned to a group, there’s no automatic behavior to update the “Assigned to” user.

There is no round robin or auto assignments for groups, out of box. There is on-call scheduling but this requires an extra license and needs to be implemented properly.

A lot of IT Managers like the idea of using platform automation to make decisions. This solution can ultimately save people a lot of time and removes a lot of manual intervention. But it’s not a “one size fits all” solution. 

Usually when any task is created, there is just a notification set up to inform all of the members of the group that the case has been created, and that someone needs to go in and take ownership of it. While this is definitely helpful, notifications decrease in impact over time as the system continues to push them out. Notifications from ServiceNow should be used only when necessary.

So what happens if you have certain groups that are repeatedly unwilling to assign cases out? This feature can be implemented and skip any need for a manual intervention when it comes to assigning cases.

We can also properly “load balance” users that come in, but that’s for another and more detailed post. This post just covers how to have ServiceNow randomly select a user from a group, whenever it is assigned to a group. It does not count nor assign to individuals completely evenly.

Why Would You Want To Automatically Assign A Case?

There are countless reasons a team might ask for this.

Common reasons are “use of automation” or “not wasting time reading and assigning cases”. The ServiceNow Platform can be enhanced to make decisions dynamically.

This could be helpful if there are teams that have trouble delegating. The system makes the decision for them. But this should also not be used as a crutch, if teams aren’t doing their work in ServiceNow, this is probably not the best solution to encourage them.

For organizations that are large enough, I have seen it be the full time job of people to manually come in and assign cases to people, on a case by base basis. This is a huge waste of resources and can be easily solved via automation efforts.

A good use case for automatically assigning a case to a user of a group when it comes in would be if all of the users of a group can equally solve the cases that come in. If there’s no large knowledge gap, then it makes sense to implement some sort of auto triaging solution.

You may be able to further expand upon the idea here. You can take the script and modify it to auto assign based on any other condition you can think of.

This solution does not count assignments and make decisions based on that. For example, if there is a group of 2 users – it could assign 4 cases to one and 6 cases to another.

Something To Also Keep in Mind – Related To SLA’s

There is a debate amonst ServiceNow professionals on when to have the “Response SLA” condition met. Some companies prefer to the Response SLA met when a case is “assigned”. Others prefer to have the Response SLA met when the case has a fulfiller add a comment. That’s for you and your organization to decide.

But if your company has your Response SLA conditions set up to be met when an incident has an “Assigned to” user populated – then continue reading here. If that is the case, then the Response SLA will be instantly met, and will become a metric that doesn’t provide a lot of value. If all your incidents are being assigned on insert, then 100% of the SLA’s measuring response will be met on insert, and won’t even be tracked. It will appear that you are meeting 100% of responses, every time.

So be aware of this if you decide to implement this functionality.

How To Automatically Assign A Case At Random?

The solution here is a rather straightforward business rule.

Table Task Table in question, Incident for example
Insert true
Update true
When Before

Condition: current.assignment_group.changes() && current.active == true && current.assigned_to == ”

Note: You will likely want to update this condition. This condition will auto assign cases for EVERY group that exists.

So if you only want to limit this to certain groups, make sure to define that in the condition.

Script:

(function executeRule(current, previous /*null when async*/ ) {
// Call the function
random();

// Define the function
function random() {
var group = current.assignment_group.toString();

// Find the group members of the current group
var grMembers = new GlideRecord(“sys_user_grmember”);
grMembers.addQuery(“group”, group);
grMembers.query();

var array = [];

// Add them all to an array

while (grMembers.next()) {

var user = grMembers.user.toString();
array.push(user);
}

var arrayLen = array.length;

// Randomly select the user from the elements in the array
var randomUser = array[Math.floor(Math.random() * arrayLen)];

var userName = new GlideRecord(‘sys_user’);
userName.get(randomUser);

// This is optional, but could be helpful
current.work_notes = “Auto assigning ” + current.number + ” to random user: ” + userName.first_name + ” ” + userName.last_name;

// Set the randomly found user in the group
current.assigned_to = randomUser;
}

})(current, previous);

How To Test The Auto Assignment Business Rule

Go to the table that you created the rule against. For my example, I am used the incident table and didn’t limit it to any group, just for the example.

Create an incident and assign it to any group. Make sure not to populate the “Assigned to” field.

At this point, once you save/update the record – it should auto assign to a user in that group.

Are there other ways to accomplish this feature? Is your IT Organization doing something differently to handle this?

Go ahead and take the code above and improve upon it. The above script is just an idea of what you can accomplish.

Leave a Comment