How to schedule a flow to run fortnightly

If you require to schedule a flow to run/execute on a specific day every alternative week (fortnightly), please follow the instructions below:

Illustrated in the image below is an example of a flow that will get a date from a buffer and check it against the current date. If the dates match then a new date is saved to the buffer and the flow is executed based on the first condition and via a Sync Flow destination step. If the dates do not match, it will go in the sub-flow in the 2nd condition and will not execute the required flow.

  1. Create a Buffer to store the Date for the flow execution as shown in the below image.

  1. Add and set the Schedule trigger to run every Saturday at 5 am as per the example in the below image.

  1. Add a Buffer Query source step to get the Date that is stored in the buffer that was created in the 1st instruction as illustrated in the below image.

  1. A Calculator step is used to get the current date and the return the output as an object as shown in the image below.

  1. In the Condition Control step, there are two clauses. The first condition will execute if the dates are equal or the second condition will execute if the dates are not equal.

The code that are inputted for each condition are below:

Condition 1: return input.record.eveDate === input.record.curDate;
Condition 2: return input.record.eveDate !== input.record.curDate;
  1. In Condition 1, add a Start Flow source step followed by a Calculator step to create a new Date object. Input the code to add 14 days to the current date, format it to a string (YYYY-MM-DD) and store it in a new variable called newdate as shown in the below image.

The code is below:

let inputRecord=input.record.eveDate;

let date = new Date(inputRecord); // create a new Date object with the initial date
date.setDate(date.getDate() + 14); // add 14 days to the date object
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0'); // add leading zero if month is single digit
const day = String(date.getDate()).padStart(2, '0'); // add leading zero if day is single digit
const newdate = `${year}-${month}-${day}`; // format the new date string
return {EvalDate:newdate};
  1. The new date value is then inserted into the buffer using the Buffer destination step. The Purge Before checkbox is ticked to purge the buffer to delete the old value as illustrated in the image below.

  1. In the image below, the Synchronous flow step is added to reference the required flow to execute/run. In this example, the flow that is being referenced will create a report and send it bi-weekly.