function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
vanessa veronvanessa veron 

display in the table

Hello, I am trying to get the value of the last run of each JOB and introduce a table.
I have to use another variable and not PreviousFireTime of CronTrigger because I will treat this data with other values ​​before you present it.

Somebody help me, the code displays the date of the last JOB only.

APEX:
.........
variableA = [SELECT  CronJobDetail.Name, CreatedDate, State, PreviousFireTime, NextFireTime,CronExpression FROM CronTrigger where OwnerId = '00524'];
public String infoLastExec{get;set;} 
Datetime getPlan;
 
    for(CronTrigger a: variableA){
                getPlan = a.PreviousFireTime;
                infoLastExec = getPlan.format();
            }

.............
Visualforce:
<apex:column headervalue="Last Executi" value="{!infoLastExec}"/>

Result:
01/07/2014 17:00
01/07/2014 17:00
01/07/2014 17:00

Thank you!!!
sivaextsivaext
Hi

create a variable in finish method to capture last fire time because once complete all batches then oly enter into finish method

Are you testing batch class more than 200 records?
vanessa veronvanessa veron
Thank you...

Can you give me an exemple?

==> Are you testing batch class more than 200 records? NON
sivaextsivaext
Hi 

global class  batchjob implements database.batchable<sObject>{
       global database.getQuerylocator start (Database.BatchableContext BC){
      
       }

       global viod execute(Database.BatchableContext BC, List<sObject> scope){

       }
        
       global void finish(Database.BatchableContext BC){
               Datetime dt = datetime.now();
               system.debug('the last transaction date' + dt);
       }

}