Scheduled Job Options or Scheduled Flow Trigger Options

neil_b
Tera Guru

I have an approval reminder notification that is to be sent out on Mondays at 8AM and Thursdays at 8AM. Unfortunately, when I try to schedule a flow trigger or a scheduled job, I only have options such as Daily, Weekly (which does not allow multiple days), Periodically (which doesn't allow exact days), or Monthly.

 

Is it possible to configure this notification on one scheduled job or one flow? I would like to avoid creating two separate jobs or flows for this same action. I just need to be able to schedule it for two days a week at the same time, but I know if this can be achieved. If it is possible, can someone please help me out? 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@neil_b 

you will require 1 scheduled job which runs daily at 8AM

In the condition field check if it's Monday or Thursday, if yes then run the job script

Adjust the script based on which day is configured as start day of week

glide.ui.date_picker.first_day_of_week

Setting Monday as the first day of the week in the calendar 

answer = false;
var today = new GlideDateTime();
var dayOfWeek = today.getDayOfWeek(); // 1 = Sunday, 2 = Monday, ..., 7 = Saturday
if (dayOfWeek == 2 || dayOfWeek == 5) { // 2 = Monday, 5 = Thursday
    answer = true;
}

AnkurBawiskar_0-1742317599234.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

4 REPLIES 4

Joe Wong
Tera Guru

You are right, the way I get around this on ServiceNow is to run a script like this:

var gdt = new GlideDateTime();
// this script only runs on Jan/April/July/Oct
if (gdt.getMonthLocalTime() == 1 || gdt.getMonthLocalTime() == 4 || gdt.getMonthLocalTime() == 7 || gdt.getMonthLocalTime() == 10) {
    var obj = new global.ScheduledFMPTasksFilters().scheduleTasks();
}
 
You can use different gdt functions as you see fit.  Then I have the Schduled Script Execution everyday or every month depending on your frequency. 

@Joe Wong where are you inserting this script? In the conditional script section of the scheduled job or did you create a script include and call the script include?

Ankur Bawiskar
Tera Patron
Tera Patron

@neil_b 

you will require 1 scheduled job which runs daily at 8AM

In the condition field check if it's Monday or Thursday, if yes then run the job script

Adjust the script based on which day is configured as start day of week

glide.ui.date_picker.first_day_of_week

Setting Monday as the first day of the week in the calendar 

answer = false;
var today = new GlideDateTime();
var dayOfWeek = today.getDayOfWeek(); // 1 = Sunday, 2 = Monday, ..., 7 = Saturday
if (dayOfWeek == 2 || dayOfWeek == 5) { // 2 = Monday, 5 = Thursday
    answer = true;
}

AnkurBawiskar_0-1742317599234.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@neil_b 

Thank you for marking my response as helpful.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader