Automic Workload Automation

 View Only

 Java API: How to get the next start time of a JobPlan

Chris Taubenheim's profile image
Chris Taubenheim posted Jan 11, 2022 06:36 AM

Hi All,
I currently have the problem that I want to get the 'next Run' time for a JobPlan.

Here's what I'm doing

TaskFilter taskFilter= new TaskFilter();
taskFilter.selectAllObjects();
taskFilter.selectAllPlatforms();
taskFilter.setStatus(TaskFilter.ANY_WAITING + "," + TaskFilter.ANY_ACTIVE);
List<Task> act = broker.activityWindow.getActivityWindowContent(taskFilter);
for (Task t : act) {
  if(t.getStatus().equalsIgnoreCase("state_sleeping")) {
    ScheduleMonitor sm = new ScheduleMonitor(t.getRunID());
    conn.sendRequestAndWait(sm);
  }
}

After getting the ScheduleMonitor I'm expecting that the tasklist of this object is conaining at least one 'com.uc4.communication.requests.ScheduleMonitor.Task' where I can read out the 'nextStart' .
But instead it does not contain any tasks.
Is there something I did wrong to get the next execution time of a scheduled Object?

Any help is much appreciated.
Thanks in advance.

Chris Taubenheim's profile image
Chris Taubenheim
In the meantime I tried a lot and guess I found the solution.
GetExecuteOnce eo = new GetExecuteOnce(t.getRunID());
conn.sendRequestAndWait(eo)
DateTime nextExecution = eo.getExecutionDateTime();​

This gives me the next execution time wether it's a Single scheduled execution or a recurring one.
Hope there's someone who can verify that this is a valid way I'm going.

Thank you.