The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Prevent notifications to be sent in holidays using flow designer

navajezuz
Giga Contributor

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:

https://www.servicenow.com/community/developer-forum/scheduled-flow-on-workdays/m-p/2161492#:~:text=...

 

this one too:

https://www.servicenow.com/community/developer-articles/flow-designer-action-quot-verify-inside-sche...

 

and I already built the action based on the link above:

Captura de pantalla 2025-08-22 a la(s) 1.51.12 p.m..png

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

1 ACCEPTED SOLUTION

pavani_paluri
Giga Guru

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 it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Pavani P

View solution in original post

2 REPLIES 2

pavani_paluri
Giga Guru

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 it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Pavani P

Thank you very much!