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

getDayOfWeekLocalTime(); will output the day in the users time zone. Unless otherwise specified on the user record, the user will have the system time zone.


3.21 getDayOfWeekLocalTime()

Gets the day of the week stored by the GlideDateTime object, expressed in the user's time zone. This method is available starting with the Eureka release.


3.21.1 Input Fields

Parameters:


  • None

3.21.2 Output Fields

Returns: (int) The day of week value, in the user's time zone, from 1 to 7. Monday=1, Sunday=7.




ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

HI Nancyhz,



Please go through the script section 3.2 here.


Creating a Scheduled Job - ServiceNow Wiki


Deepak Ingale1
Mega Sage

Can you please also elaborate what the thought process behind this requirement?


When the user send an email to open an incident, the State vale of new incident must be set to "New" if it is not in business hours (7:am - 7:pm Monday-Friday, or weekend (Sat-Sunday).   However, the State value of new incident ticket must be converted to "Active" if days are not weekend, or time is in business hours during weekday.



I hope my requirement is clear enough for you


Hi Nancyhz,



In that case(Considering Business hours), It would make more sense to go with Schedules. That would be a scalable approach.



Thanks


Srini