Help with script for timer

John Vo1
Tera Guru

Can someone help me with a script that will create a task in 1 week from the start date?

So for an onboarding request HR will enter a start date.  I want a task created in 1 week from that start date on the catalog item.

Here is my workflow 

This is what's in my timer.  But when I ran my test it creates the 1 week follow up task.

1 ACCEPTED SOLUTION

Steven Parker
Giga Sage

The timer activity is based on seconds when scripting.  There are 86400 seconds in a day.  So multiply that by 7 days and you get 604800.

So in your timer activity change the "Timer Based On:" field to "Script" and then use the following script:

answer = 604800;

 

That's in seconds...so you can always test it by putting 120 in there and see if it waits 2 minutes before creating your 1 week task.

 

Here is an example from our instance from a "Timer Activity" where we wait until the "Travel End Date" from a catalog item before proceeding in the workflow:

// Set 'answer' to the number of seconds this timer should wait
answer = gs.dateDiff(gs.now(), current.variables.end_date.getDisplayValue(),true);

Please mark this response as correct and/or helpful if it assisted you with your question.
Steven

View solution in original post

6 REPLIES 6

Put a Run Script after your timer.

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster

Steven Parker
Giga Sage

The timer activity is based on seconds when scripting.  There are 86400 seconds in a day.  So multiply that by 7 days and you get 604800.

So in your timer activity change the "Timer Based On:" field to "Script" and then use the following script:

answer = 604800;

 

That's in seconds...so you can always test it by putting 120 in there and see if it waits 2 minutes before creating your 1 week task.

 

Here is an example from our instance from a "Timer Activity" where we wait until the "Travel End Date" from a catalog item before proceeding in the workflow:

// Set 'answer' to the number of seconds this timer should wait
answer = gs.dateDiff(gs.now(), current.variables.end_date.getDisplayValue(),true);

Please mark this response as correct and/or helpful if it assisted you with your question.
Steven