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

I'm back! New day, new brain.



I discovered the issue was with my table setup.



I had a typo in one of the table names.



The good news is that everything is now working as it should! It's perfect, lovely, and I'm having no trouble. Helsinki still loves your code. The bad news is that now I feel like I've got egg on my face!!



Thanks for the help.


Not at all... I'm super glad you got the issue fixed.   Thanks for the update.  


Another question for you, if you can bear with me!



I'm trying to skip the round robin logic if the caller/requester is a VIP. I'm trying this:



function __initBR()


{


// Get the sysID of the needed Group


var gr = new GlideRecord('sys_user_group');


var caller = g_form.getReference('requester'); // Looks to requester field on incident form


gr.addQuery('name', groupName); gr.query();


if (gr.next())


groupSysID = gr.sys_id.toString();


if (current.assignment_group == groupSysID && caller.vip == false) // Is VIP false?


    {


current.assigned_to = resolveTech();


    }


} __initBR();



...buuut this isn't working at all.



Still trying some things, but I would appreciate some guidance! Nothing quite like learning by doing.


And now I've tried this!



function __initBR()


{


var caller = g_form.getReference('caller_id');


if (caller.vip == false) {


  // Get the sysID of the needed Group


  var gr = new GlideRecord('sys_user_group');


  gr.addQuery('name', groupName); gr.query();


  if (gr.next())


  groupSysID = gr.sys_id.toString();


  if (current.assignment_group == groupSysID)


    {


    current.assigned_to = resolveTech();


}


    }


} __initBR();



Still no luck. Hrrm. Does this need to be its own function, I wonder?


Disregard my questions -- I found the answer I needed, and it was very simple.



See this separate post: How to skip Business Rule for Incidents if caller/requester is VIP?