How to detect weekend days

nancyhz
Mega Contributor

I got a requirement -all incident are opened during weekend , their State field must be set to "New".     However, their State value -"New" must be converted to "Active" if date is coming to Weekday (Monday - Friday).     How can I monitor the date change among Weekend to Weekday?

14 REPLIES 14

How can we check on time: Business hour 7:00 am - 7:00 pm in Scheduled Job script?


nancyhz
Mega Contributor

I created the following BR "Before-Insert to meet the requirement -State value is "New" after business hour 7:00 am to 7:00 pm and "Active" for business hours, but for hour checking is not as expected.   Any suggestion?



find_real_file.png


Hi nancy,



you might want to try out this script between your execute rule



var gdt = new GlideDateTime();


var day =   gdt.getDayOfWeekLocalTime();



if(day == 6 || day == 7) {



  current.incident_state = 1;


} else {



    var dateAndTime =   gdt.toString().split(" ");


    var time =   dateAndTime[1].split(":");


    var hour = time[0];


    if (hour >= 7 && hour < 20 ) {


  current.incident_state = 2;


  } else   {



  current.incident_state = 1;


  }



}



Thanks


Venkat


It worked.   Thank you for your support, Venkat


Thank you for your explanation.


I had understood the requirement, but I was interested in the thought process behind why this kind of configuration is needed.


Normally, your incident created moves to "New" state irrespective of the day. In most of the implementations, moving state to "Active" is the indication for "Completion of Response SLA".