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

Hi,

Hoping you can help out here - the above works well in the Global scope - however I'm trying to use it in the HR Scope and it produces an error that states 'Function dateDiff is not allowed in scope sn_hr_core.  Use GlideDateTime.subtract() instead'.

 

Not being a scripter I haven't managed to get this to work - would you be able to translate your code above to do the same thing but with the GlideDateTime?

 

Thanks Carl.