Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Schedule flow for the 1st Friday of every quarter

Brian Lancaster
Kilo Patron

I need to have a flow that triggers the first Friday of every quarter. What is the best day to do this?

1 ACCEPTED SOLUTION

Anks26
Kilo Sage

Hi Brian,

Unfortunately, this is not yet possible, however you can create a subflow and then trigger it via scheduled job. 

Please see KB0961745 for reference. 

You would run the scheduled job weekly on a Friday and check if its the first month of the quarter and then since a Friday should occur in First 7 days it should only come true once in that month. 
Your script condition  should be something like this but please test it in non-prod

var answer = false;
var now = new GlideDateTime();
var month = now.getMonth();
var day = now.getDayOfMonth();
if ((month == 1 || month == 4 || month == 7 || month == 10) && day <= 7) {
    answer = true;
}
answer;




Hope this helps

Thanks
Anks


View solution in original post

5 REPLIES 5

Anks26
Kilo Sage

Hi Brian,

Unfortunately, this is not yet possible, however you can create a subflow and then trigger it via scheduled job. 

Please see KB0961745 for reference. 

You would run the scheduled job weekly on a Friday and check if its the first month of the quarter and then since a Friday should occur in First 7 days it should only come true once in that month. 
Your script condition  should be something like this but please test it in non-prod

var answer = false;
var now = new GlideDateTime();
var month = now.getMonth();
var day = now.getDayOfMonth();
if ((month == 1 || month == 4 || month == 7 || month == 10) && day <= 7) {
    answer = true;
}
answer;




Hope this helps

Thanks
Anks


That seems a little strange way to do it to me to use both subflow and scheduled jobs. So what I did is create an action with your code in it. Then I have the flow run weekly on Friday. If the action returns false I immediately end the flow. Otherwise it continues. I guess I will find out next Friday if it worked.

Ratnakar7
Mega Sage

Hi @Brian Lancaster ,

 

To trigger a flow on the first Friday of every quarter, you can use a schedule that runs on a quarterly basis and then add a condition to check if the current day is the first Friday of the quarter.

 

Thanks,

Ratnakar

Marcus Walbridg
Tera Expert

I did something similar to Anks.  I have a scheduled script to run daily to check the month and day.  If it meets those conditions I use the flow API to run my flow.  Otherwise you could set the flow to trigger when a certain event is made, and have the script make that event