VMware Cloud Community
SlingBlade20111
Contributor
Contributor
Jump to solution

Schedule Task X days (or hours) after workflow started

I'm new to Orchestrator so please forgive my ignorance...

I'm building a workflow that allows our users to create their own snapshots.  We have a policy that snapshots can only be kept for a maximum of 3 days.  My inputs would allow the user to select the number of days (I'm cool with using hours if it's easier) until the snapshot is automatically committed.  How would I accomplish this?  Is there a method to take the current date/time (at the time the workflow is run) and add X days (or hours) to schedule a task that commits the snapshot?

Alternatively, is there a way to present a calendar and only allow them to select up to 3 days from the current date?

Thanks for any contributions

Reply
0 Kudos
1 Solution

Accepted Solutions
Burke-
VMware Employee
VMware Employee
Jump to solution

Here's a snippet of code that will help you:

var now = new Date();

System.log("Now is: " + now);

var newDate = new Date();

newDate.setDate(now.getDate() + 3);

System.log("Now + 3 days is: " + newDate);

Sample Output:

[2014-03-19 19:00:55.473] [I] Now is: Wed Mar 19 2014 19:00:55 GMT-0400 (EDT)

[2014-03-19 19:00:55.474] [I] Now + 3 days is: Sat Mar 22 2014 19:00:55 GMT-0400 (EDT)

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter

View solution in original post

Reply
0 Kudos
2 Replies
Burke-
VMware Employee
VMware Employee
Jump to solution

Here's a snippet of code that will help you:

var now = new Date();

System.log("Now is: " + now);

var newDate = new Date();

newDate.setDate(now.getDate() + 3);

System.log("Now + 3 days is: " + newDate);

Sample Output:

[2014-03-19 19:00:55.473] [I] Now is: Wed Mar 19 2014 19:00:55 GMT-0400 (EDT)

[2014-03-19 19:00:55.474] [I] Now + 3 days is: Sat Mar 22 2014 19:00:55 GMT-0400 (EDT)

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
Reply
0 Kudos
SlingBlade20111
Contributor
Contributor
Jump to solution

Thank you Burke!  This worked perfectly!

Reply
0 Kudos