Sunday, December 18, 2022

Scheduling Batch Class after 6 minutes whenever a batch finish method executed in salesforce

AsyncApexJob a = [SELECT Id, Status, NumberOfErrors, JobItemsProcessed,

         TotalJobItems, CreatedBy.Email

         FROM AsyncApexJob WHERE Id =:BC.getJobId()];


* Above syntax is to retrieve information regarding to the jobs.

             Batch_classname bs = new Batch_classname();

             Datetime sysTime = System.now();

             sysTime = sysTime.addminutes(6);

             String chron_exp = '' + sysTime.second() + ' ' + sysTime.minute() + ' ' +

             sysTime.hour() + ' ' + sysTime.day() + ' ' + sysTime.month() + ' ? ' + sysTime.year();           

             System.schedule('Update Actual'+sysTime.getTime(),chron_exp, bs);

No comments:

Post a Comment

Understanding Wire vs Imperative Apex Method Calls in Salesforce Lightning Web Components (LWC)

Understanding Wire vs Imperative Apex Method Calls in Salesforce Lightning Web Components (LWC) Introduction: Salesforce Lightning Web ...