How to send a email twice in a day only on business days.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2024 02:32 AM - edited 06-16-2024 10:09 PM
Code:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2024 09:14 AM
Hi Pavan,
Assuming that your notification is set up for table = change_request, you should be fine. The simple way to run things twice daily is to set up two jobs. To only run it on business days, add something like this to your script or create a condition:
var theDT = new GlideDateTime();
var theDTDay = theDT.getDayOfWeek();
if (theDTDay < 6) {
//add your existing code here
}
That will give you weekdays. If you need to consider holidays, that gets a lot more complicated because you need to reference calendars and possibly other values depending if you are international, etc.
If you want to run everything from one job, just enhance the above script so that after determining the day of the week, you evaluate the current time and if it matches your timing for sending out notices execute your existing script.
Before setting this up, check that your calendars treat Monday as day 1. If not, adjust the logic in the above script to conform.
:{)
Helpful and Correct tags are appreciated and help others to find information faster