dhananjay_malpu
I'm new here

Schedule Entry Execution

Jump to solution

Hi All,

Greetings !!

Could you please let me know on following query :

I have existing schedule entry setup on the server. I am trying to update existing schedule entry execution time with future time (+5 minutes from current time) using below code snippet but I am unable to see updated entry in Scheduling -> planned schedule entries :

Code snippet :

executeUserFutureScheduleTask(String schedulename) {
     currentProject = context.getProject();
     scheduleStorage = context.requireSpecialist(ServicesBroker.TYPE).getService(AdminService.class).getScheduleStorage();
     scheduleEntry = scheduleStorage.getScheduleEntry(currentProject,schedulename) ;
     executionSchedule = scheduleEntry.getExecutionSchedule() ;

     Calendar cal = Calendar.getInstance();
     cal.add(Calendar.MINUTE, 5); //increasing current time by 5 minutes
     Date updatedScheduleDate = cal.getTime();

     if(executionSchedule != null ) {
          executionSchedule.setNextExecutionTime(updatedScheduleDate) ;
     }

      //control = scheduleEntry.execute();
     //control.awaitTermination();
}

//calling the function by passing schedule name

schedulename = "Operationalsite Schedule Test";
executeUserFutureScheduleTask(schedulename) ;

Kindly note : If I uncomment below two commented lines ( from above code snippet ) then schedule task will be executed immediately even thought it's scheduled as a future schedule entry.
//control = scheduleEntry.execute();
//control.awaitTermination();

Many thank you in advance.

Cheers
Dhananjay

0 Kudos
1 Solution

Accepted Solutions
Peter_Jodeleit
Crownpeak employee

Try first "lock()", than do your modification, than "save()" and "unlock()".

"execute()" is for immediate execution, so it's behaving correctly.

Peter

View solution in original post

0 Kudos
3 Replies
Peter_Jodeleit
Crownpeak employee

Try first "lock()", than do your modification, than "save()" and "unlock()".

"execute()" is for immediate execution, so it's behaving correctly.

Peter
0 Kudos

Hi Peter,

Thank you. It worked for me Smiley Happy

0 Kudos

Hello,   

do you need further help or did Peters's reply already help you? If so, it would be great if you marked

his reply as "correct answer" so that other community users find the solution easily. If you have

already found a solution by yourself, it would be very kind of you, if you posted it here.   

Best regards 

Thorsten

0 Kudos