Round-Robin (Auto Assignment of new incidents and tasks)

magoo
Kilo Expert

HI All,

 

I was asked to create a round-robin type approach (Auto Assignment) for any incidents/tasks that come into our two level1 groups. What we are looking for is that if its sent to team A's group it will auto assign to the next team member in line, and same with Team B.   I have searched the forums and found a post back from 2008 but it had been deleted by ServiceNow in 2010.   Our company is new to ServiceNow (a couple months now), and I am guessing this is more of a script that would need to run, but currently do not have much experience in scripting.   Has anyone had any luck with doing something like this?   Any suggestions would be greatly appreciated!

 

Thanks!

1 ACCEPTED SOLUTION

justin_drysdale
Mega Guru

We have this in our instance.   Here's the breakdown:



On sys_user, create a date/time field to track last ticket assigned. Also create a checkbox that will be used to determine if the user can receive a ticket.   This can be your vacation exclusion logic.



1. Make an array (associative, key-value) to contain your users that will receive tickets and their corresponding last ticket assigned timestamp.


2. Find your assignment group, and query it's users.


3. Push those users and timestamp into the user array from 1.   You can conditionalize here with the checkbox to make sure you are only pushing 'active' users into the array.


4. Sort the array by timestamp, return the user that has the oldest timestamp.


4.5. Update the user's timestamp.


5. assigned_to = returned user.



Please let me know if you have any questions.


View solution in original post

102 REPLIES 102

Harneet Sital
Mega Sage
Mega Sage

Hi,



The scenario can be handled with the following script as well.



// The following script will store the users into an array grpUsers.


//getRowCount() will give number of total users in the group



              var grpUsers = '';


      var getgrpUsers = new GlideRecord('sys_user_grmember');


      getgrpUsers.addQuery('group','287ee6fea9fe198100ada7950d0b1b73');


      getgrpUsers.query();



      gs.log(getgrpUsers.getRowCount());



      while(getgrpUsers.next())


      {


                grpUsers = grpUsers + ',' + getgrpUsers.user;


      }



gs.log(grpUsers);




// The following logic will allocate new incidents to the group with round robin algorithm.



Modulus the Incident ID with the the row count you will some value less than the rowcount value. Now the returning value of the modulus operation can be passed to the Users array and corresponding nth User will be allocated with the incident. To get all the active users make a new query as active is true on the same sys_user_grnumber table.



      var newID = g_form.getValue('number');



      var Mod = newID % getgrpUsers.getRowCount();



Next assigned to will happen on the grpUsers [Mod]



Hope this might work as well for your scenario.




Regards,


Harneet Sital


Blaze2
Kilo Guru

I know this is an old post, but does anyone have any screen shots of the step by step that they did to achieve this?



Thanks


Hey Blaze,



I did this a long time ago with the help of a Lab from K14.   If you drop me your email, I'll send you the PDF.   That should get you started.   Our particular instance of this round robin also used the Schedule table and some changes to User to see which person was on shift, instead of using groups.   I don't have that as documented as the lab, but if you are trying to do it by individual and not by groups as they are here in the Lab, let me know.


Thanks!


Cal


Hi Cal,



I am trying to implement the same round-robin approach of auto assignment, it would be very helpful if you could send me the PDF.


My email id is : sharmapurnima773@gmail.com



Thanks in advance.



Regards,


Purnima


I did just that, Blaze, and put it all in a PDF format for convenience here:     Re: Round-Robin (Auto Assignment of new incidents and tasks)