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.

Workflow timer to wait for if today is five days from the "effective date"

Nathan Okh
Mega Sage

I'm trying to kick off a workflow task that will wait until today is 5 days from the "effective date" before kicking off the rest of the workflow creating a task etc.

 

Is this possible using the condition builder? A script will do.

Thanks!

2 REPLIES 2

James Chun
Kilo Patron

Hey @Nathan Okh,

 

I am assuming it's Workflow not Flow, if so you can use a Timer workflow activity.
An example below:

JamesChun_0-1710272654257.png

// Set 'answer' to the number of seconds this timer should wait
var effectiveDate = new GlideDateTime(current.variables.getValue('effective_date'));
effectiveDate.addDays(5);

var nowGDT = new GlideDateTime();

answer = gs.dateDiff(nowGDT, effectiveDate, true);

 

Note that if you update the 'effective date' after the activity is executed, the timer will NOT reset.

 

Cheers

 

Sumanth16
Kilo Patron

Hi @Nathan Okh ,

 

 

If you're getting the value from a form field, set the value for Timer based on "A date/time or duration field" and then select your field.

 

If you're getting it from a variable, set the value for Timer based on "Script", then in the script field use the code below.



 

answer = gs.dateDiff(gs.nowDateTime(), current.variables.term_date, true);

 

 

 

If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!

 

Thanks & Regards,

Sumanth Meda