- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2020 04:58 AM
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2020 06:41 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2020 06:24 AM
Put a Run Script after your timer.
Hope that helps.
:{)
Helpful and Correct tags are appreciated and help others to find information faster
:{)
Helpful and Correct tags are appreciated and help others to find information faster
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2020 06:41 AM
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