LaxmiRagi
Enthusiast
Enthusiast

Schedule workflow by script

Hi There,

I am getting "InternalError: Cannot schedule workflow: Task "test-workflow" is planned in the past " while scheduling the workflow by script

Code:

var recurrenceCycle = "every-minutes";

var recurrencePattern = '1';

dteStartDate = '2019-10-11 08:10:00'

dteStartDate = '2019-10-12 08:10:00'

var prop = {

           // workflow properties

}

var task = workflowToSchedule.scheduleRecurrently(props, recurrencePattern, recurrenceCycle, dteStartDate, dteEndDate);

task.restartInPast = true;

Please help me out to overcome this issue.

Regards,

Laxmi

0 Kudos
3 Replies
iiliev
VMware Employee
VMware Employee

Hi,

Dates should not be strings but a proper Date objects. Also, I see two dteStartDate initialization calls but not dteEndDate. And it is not clear what was the time when you ran and received this error (eg. was it before the start date, and what it the timezone where your client is running?)

Could you post the exact scripting code? Also, which vRO version is this?

0 Kudos
LaxmiRagi
Enthusiast
Enthusiast

Hi,

I have so much business logic in it before scheduling the workflow, that why I have given a rough example.

Problem Statment:

This problem has occurred when we scheduling the workflow with the past date, I have tried through vRO(vRO7) by selecting past date look like its working fine but when I do it by a script(programmatically) it is throwing an exception saying Task "test-workflow" already planned in the past!!.

Q1.  is vRO allows past date while scheduling

Q2. what is the parameter to set value  for "Don't run if task planned in the past"[ this will appear in the vRO dropdown]

Q3. how to update(like start-date,end-date, schedule suspend and resume) a task by script?

Thank you in advance.

--

Laxmi

0 Kudos
iiliev
VMware Employee
VMware Employee

The problem is that the flag restartInPast has to be set on the task object returned by the call to scheduleRecurrently(), where the error is thrown, and there is no parameter to pass it earlier.

You can cancel/suspend/resume task by calling the corresponding methods on the task object returned by call to schedule()/scheduleRecurrently(). Check API Explorer documentation for Task scripting class.

0 Kudos