How to detect weekend days
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2016 08:47 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2016 08:50 AM
Hi Nancy,
I believe you will have to create scheduled jobs and you will have create a script into that and based on that it will change the value in the backed.
Regards,
Atul Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2016 09:03 AM
I would make a Schedule with the the weekends etc. and then make a Before Insert BR that checks if the date is within the schedule(weekdays) or outside(weekend) and depending on value it will set new or active. The have a schedule job each morning making the same check and turning the "new" to "active" if it's a weekday
That schedule perhaps already exists and used by the SLA.
don't know if the first part is needed for you thou.
//Göran
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2016 09:20 AM
Hi Nancyz,
A Before Business rule with Below code should do.
var dateTime=new GlideDateTime();
var day=dateTime.getDayOfWeekLocalTime();
if(day==6 || day==7){
current.incident_state=1; // New State value
}
else{
current.incident_state=2; // Active state value
}
More on wiki here GlideDateTime - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2016 10:46 AM
Thanks, Srinivas for your suggested codes. We are using "us eastern time zone" as default system time for all date time calculation. can I still use "getDayOfWeekLocalTime();"?