Create custom time-based triggers for Flow Designer - every 2nd Tuesday of the Month

Peter Williams
Kilo Sage

Hello all

Happy New Years.

 

i have a requirement to create a custom time base trigger for Flow designer

what i need to do is:

 

1) have the trigger run every 2nd Tuesday of the month

2) have another trigger to run every 2nd Tuesday of a specific month ( ex. 2nd Tuesday of Jan. or 2nd Tuesday of Oct.)

 

i know that i can set the trigger to run daily but how do i calculate to for the other items above

 

 

any and all help is appricated 

6 REPLIES 6

How would i incorporate this into the Flow Designer to check?

 

i am looking at the Scheduled Jobs in System Definations

 

i think it could work but i am not able to get the condition to work correctly

 

here is what i have

PeterWilliams_0-1713465429860.png

 

here is the condition script

// Condition Script
(function checkCondition() {
    // Get the current date
    var currentDate = new GlideDateTime();
    // Check if it's Tuesday
    if (currentDate.getDayOfWeek() == 3) { // Tuesday is represented as 3 in ServiceNow
        // Check if it's between the 8th and 14th day of the month
        if (isSecondTuesday(currentDate)) {
            // Condition is met
            return true;
        }
    }
    // Condition is not met
    return false;
})();

// Function to check if the date is the second Tuesday of the month
function isSecondTuesday(date) {
    var dayOfMonth = date.getDayOfMonth();
    // Check if it falls between the 8th and 14th day of the month
    return dayOfMonth >= 8 && dayOfMonth <= 14;
}
 
 
cant see to get it to work correctly