Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

How to auto-assign an incident ticket to an specific support group after normal working hours?

feibian
Kilo Contributor

Hi Everyone

I would like to know if Is there a way I can route to an specific group of high/critical tickets that are received outside of normal working hours?

Scenario:  

7 am to 7 pm tickets should be routed to "AAA support group"

7 pm to 7 am and weekends high/critical tickets should be routed to "BBB support group"

Your help on this will be appreciated

Fabian GR

1 ACCEPTED SOLUTION

Neither of those will work, for two different reasons.



Use the below, EXACTLY as is:



var g = new GlideRecord('cmn_schedule');


g.addQuery('name', 'Normal working hours');


g.query();


if (g.next()) {


    var sched = new GlideSchedule(g.sys_id);


    var d = new GlideDateTime();


    if (sched.isInSchedule(d))


        current.assignment_group.setDisplayValue("C360 Ops Triage");


    else


        current.assignment_group.setDisplayValue("PEGA-Coverage Review");


}


View solution in original post

16 REPLIES 16

andrew_venables
ServiceNow Employee
ServiceNow Employee

You could take a look at on call scheduling, but it might be a bit over kill https://docs.servicenow.com/bundle/helsinki-it-service-management/page/administer/on-call-scheduling...



Or more simply you could define your schedule, in the the cmn_schedule table, then use a script like the below to detect if the current time is in the schedule:


var g = new GlideRecord('cmn_schedule');


g.addQuery('type', 'blackout');


g.query();


if (g.next()) {


    var sched = new GlideSchedule(g.sys_id);


    var d = new GlideDateTime();


    d.setDisplayValue("2007-09-18 12:00:00");


    if (sched.isInSchedule(d))


    gs.info("Is in the schedule");


    else


    gs.info("Is NOT in the schedule");


}



Then you could potentially put the above in a assignment rule (scripted).


Thanks Andrew for your quick response, I have not idea how to define my schedule, could you please advise?


On your instance, in the navigation bar on the left hand side, goto: System Scheduler > Schedules.


Then click the New button to create a new schedule


Give it a name of "Normal working hours"


Save the record.


When the record reloads, on the related list of "Schedule Entries", click New


Give the new record a name of "Weekdays 7am-7pm"


In the "When" field set the hours from 07:00:00 (the date doesn't matter)


In the "To" field set the hours to 19:00:00 (same date)


In the "Repeats" field set it to "Every Weekday (Mon-Fri)"



Now you have a schedule that covers every weekday 7am to 7pm.



Then use the script above, you may need to edit it to the below:



var g = new GlideRecord('cmn_schedule');  


g.addQuery('name', 'Normal working hours');  


g.query();  


if (g.next()) {  


    var sched = new GlideSchedule(g.sys_id);  


    var d = new GlideDateTime();  


    gs.info(d);


    if (sched.isInSchedule(d))    


    gs.info("Is in the schedule");  


    else  


    gs.info("Is NOT in the schedule");  


}  



Which, depending on the time you run it, will either tell you the current datetime is in or out of normal working hours.



Then you can use this in a business rule or assignment rule.


Thanks a lot Andrew for your support on this,


I have already created a new schedule named "Normal working hours", it has related the list of schedule entries suggested



find_real_file.png


find_real_file.png


I have also created the below Assignment Rule



find_real_file.png


The assignment rule has set up the script you provided me



find_real_file.png


Unfortunately it is not working , Maybe I set up the script at the wrong way



find_real_file.png


Could you please advise?