Assign the Incident between 5 members in one groups in round manner, Auto assignment of incident? Is it possible ?

SNOW44
Mega Guru

Hello All, 

I have a recruitment like Auto- assign Incident between 5 members of one groups and rotate format. When ever a new incident created it auto assign as below

eg:

* Case 1 - assigned to User 1

* Case 2 - assigned to User 2

* Case 3 - assigned to User 3

* Case 4- assigned to User 4

* Case 5- assign to User 5

Repeat again from User 1

it will be like rotate format, can anyone help me on this 

Thanks in Advance

1 ACCEPTED SOLUTION

Ian Mildon
Tera Guru

Yes it is entirely possible to do that, I have a business rule that is doing "round robin" assignment of Incidents to our service desk techs; based on the time the Incident is submitted, and who has the least workload.

And I've broken this out a couple of times today on here now:

function executeRule(current, previous /*null when async*/ ) {

    //assign to the group check
    if (current.active == true) { //removed un-needed assignment group value
        var schedRec = new GlideRecord('cmn_schedule');
        schedRec.get('name', '8-5 weekdays excluding holidays'); //schedule name
		var sched = new GlideSchedule(schedRec.sys_id);
		
        if (sched.isInSchedule(new GlideDateTime()) && current.assigned_to == '') { //check schdule and assign
            var grMemRec = new GlideRecord('sys_user_grmember');
            grMemRec.addQuery('group', current.assignment_group);
            grMemRec.addQuery('user.u_primary_group', 'ca3475badb05b240ec5c3c00ad9619b2'); //only include if primary group is also ISD Service Desk
            grMemRec.addQuery('user.u_auto_assign', 'true'); //checkbox on profile
            grMemRec.orderBy('u_last_incident_assigned');
            grMemRec.query();
            if (grMemRec.next()) {
                current.assigned_to = grMemRec.user.getDisplayValue();
                grMemRec.u_last_incident_assigned = gs.nowDateTime();
                grMemRec.setWorkflow(false);
                grMemRec.update();
            }
        }
    }

})(current, previous);

There was a "workbook" from a previous Knowledge conference that gave the full step by step process of building this out. I do have an old copy somewhere but if you search for "round robin assignment" or similar you may track down a copy.

View solution in original post

7 REPLIES 7

bammar
Kilo Sage
Kilo Sage

Its very possible. There is a Queue Manager app in ServiceNow share- not sure if its there any more.

 

But if i had to create from scratch- I would make a mechanism where a Manager can mark the users in a group Active by default- then if they take a day off mark in active.

Then BR on insert/update - If Assignment group is x and Assigned to is null and state is not Resolved/Closed -

Glidequery the group members- then assign each a random number then select the one with the highest number .

or if there is a way to pick a random member from the group with glidequery syntax

If you did the 1, 2, 3,4,5 you would need another mechanism to hold what the last number assigned was and youd worry about where to store that but if its truly random everything will work out in the end. 

Now if you want to get more advanced, you make a table to track the assignments or you log them ( maybe better as SN cleans up logs after a certain amount of time. 

Ian Mildon
Tera Guru

Yes it is entirely possible to do that, I have a business rule that is doing "round robin" assignment of Incidents to our service desk techs; based on the time the Incident is submitted, and who has the least workload.

And I've broken this out a couple of times today on here now:

function executeRule(current, previous /*null when async*/ ) {

    //assign to the group check
    if (current.active == true) { //removed un-needed assignment group value
        var schedRec = new GlideRecord('cmn_schedule');
        schedRec.get('name', '8-5 weekdays excluding holidays'); //schedule name
		var sched = new GlideSchedule(schedRec.sys_id);
		
        if (sched.isInSchedule(new GlideDateTime()) && current.assigned_to == '') { //check schdule and assign
            var grMemRec = new GlideRecord('sys_user_grmember');
            grMemRec.addQuery('group', current.assignment_group);
            grMemRec.addQuery('user.u_primary_group', 'ca3475badb05b240ec5c3c00ad9619b2'); //only include if primary group is also ISD Service Desk
            grMemRec.addQuery('user.u_auto_assign', 'true'); //checkbox on profile
            grMemRec.orderBy('u_last_incident_assigned');
            grMemRec.query();
            if (grMemRec.next()) {
                current.assigned_to = grMemRec.user.getDisplayValue();
                grMemRec.u_last_incident_assigned = gs.nowDateTime();
                grMemRec.setWorkflow(false);
                grMemRec.update();
            }
        }
    }

})(current, previous);

There was a "workbook" from a previous Knowledge conference that gave the full step by step process of building this out. I do have an old copy somewhere but if you search for "round robin assignment" or similar you may track down a copy.

How do you determine if a user is available? Meaning this looks like it would assign to someone even if the where on vacation.

By use of a field added to the sys_user table.

It is used similar to "clocking in/out" of a work shift by either the service desk techs themselves, or their manager.