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 wait for condition based on variable date

lisac
Giga Contributor

I have an offboarding workflow that needs to wait to fire Tasks until the 'term_date'.   I think i should use the wait for condition but I am not sure of the script that I should use.   Can someone assist, please?

1 ACCEPTED SOLUTION

mamann
Mega Guru

You can use a Timer activity for this.


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);



You can read about gs.dateDiff here. http://wiki.servicenow.com/index.php?title=GlideSystem_Date_and_Time_Functions#dateDiff.28String.2C_...


View solution in original post

5 REPLIES 5

rajeevlochan82
Mega Guru

1 ## you can use script like following in wait for activity. You can change the date script as per your need



(current.variables.u_term_date == gs.now())


{


answer = true


}


mamann
Mega Guru

You can use a Timer activity for this.


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);



You can read about gs.dateDiff here. http://wiki.servicenow.com/index.php?title=GlideSystem_Date_and_Time_Functions#dateDiff.28String.2C_...


zachbarr
Mega Contributor

hi there,



I am trying to something similar for offboarding a user. I have a variable of term date. I do not want the associated tasks to kick off until 24 hours before the term date.   How can i incorporate that into the above workflow?


I am wondering this too - did you ever get an answer to this please?