- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago - last edited a month ago
Hello experts, I have a flow that sends emails when a case is created, what I need is to avoid sending emails in holidays, I tried this:
this one too:
and I already built the action based on the link above:
I have couple of questions:
1. How can I add 5 hrs to the script since we work with different timezones.
2. How can I add it to the current flow to have the condition that the flow needs to check the action and decide whether the email will be sent or not. Also if the email is not sent, how can the flow be triggered again to have the email notification sent?
Thank you for your support
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Hi @navajezuz ,
Create or use a schedule in ServiceNow
This schedule should include your working hours and mark the holidays.
Example: Mon–Fri, 9 AM – 6 PM, excluding public holidays.
Build a small custom action in Flow Designer
This action will check:
“Is the current time (plus 5 hours) inside the working schedule?”
The result will be Yes or No.
Add that action to your flow
Right before sending the email, the flow will first ask:
“Am I inside working hours?”
If Yes → Send the email immediately.
If No → Do not send it yet.
Make sure the email is sent later
Use the Wait for Schedule feature in Flow Designer.
This makes the flow pause until the next working time, then it continues and sends the email.
That way, no notifications are lost — they just wait until business hours.
You can use this script inside the custom action:
var gdt = new GlideDateTime();
gdt.addSeconds(18000);
var sched = new GlideSchedule('<sys_id_of_your_schedule>', gs.getUser().getTZ());
var inSchedule = sched.isInSchedule(gdt);
outputs.is_working_time = inSchedule;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Hi @navajezuz ,
Create or use a schedule in ServiceNow
This schedule should include your working hours and mark the holidays.
Example: Mon–Fri, 9 AM – 6 PM, excluding public holidays.
Build a small custom action in Flow Designer
This action will check:
“Is the current time (plus 5 hours) inside the working schedule?”
The result will be Yes or No.
Add that action to your flow
Right before sending the email, the flow will first ask:
“Am I inside working hours?”
If Yes → Send the email immediately.
If No → Do not send it yet.
Make sure the email is sent later
Use the Wait for Schedule feature in Flow Designer.
This makes the flow pause until the next working time, then it continues and sends the email.
That way, no notifications are lost — they just wait until business hours.
You can use this script inside the custom action:
var gdt = new GlideDateTime();
gdt.addSeconds(18000);
var sched = new GlideSchedule('<sys_id_of_your_schedule>', gs.getUser().getTZ());
var inSchedule = sched.isInSchedule(gdt);
outputs.is_working_time = inSchedule;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Thank you very much!