I have a batch class which update the primary field on the quote object using batch size of 1. I need to do this in such a way that each batch is processed 30 seconds after the previous one(there needs to be a 30 second delay between each batch processing). Is there any way to achieve this?
Here is the batch class:
public class SR_SetPrimaryOnQuoteBatch implements Database.Batchable<sObject>,Database.AllowsCallouts{
public List<SBQQ__Quote__c> quotesToUpdate;
// Constructor to initialize the list of quotes to update
public SR_SetPrimaryOnQuoteBatch(List<SBQQ__Quote__c> quotes) {
this.quotesToUpdate = quotes;
}
public Database.QueryLocator start(Database.BatchableContext context) {
return Database.getQueryLocator([SELECT Id, SBQQ__Primary__c FROM SBQQ__Quote__c WHERE Id IN :quotesToUpdate]);
}
// Execute method to update the SBQQ__Primary__c field on SBQQ__Quote__c records
public void execute(Database.BatchableContext context, List<SBQQ__Quote__c> scope) {
List<SBQQ__Quote__c> quotesToUpdateBatch = new List<SBQQ__Quote__c>();
for (SBQQ__Quote__c quote : scope) {
quote.SBQQ__Primary__c = true;
quotesToUpdateBatch.add(quote);
}
// Update the records
try{
update quotesToUpdateBatch;
}
catch(Exception e){
Backend_Error__c errRec = Z_BackendErrorUtil.logError('SR_LargeDealService','syncDealLocation',e.getMessage(),'','',true);
}
}
public void finish(Database.BatchableContext context) {
}
}