ads

Wednesday 29 August 2018

Get batch status using Apex code

Code Format:


    public String BatchJobstatus {get;set;}
    Id batchJobId;

/*****call the batch class using Method******/



 public void runBatch(){
        batchContactUpdate batchObj = new batchContactUpdate();
        batchJobId = Database.executebatch(batchObj);
    }

/*****check the status of batch Using Method******/


   

 public void checkBatchStatus(){
      AsyncApexJob JobObj = [SELECT Status FROM AsyncApexJob WHERE ID =: batchJobId];
                    
       BatchJobstatus = JobObj.Status;
    }

No comments:

Post a Comment