+ Start a Discussion
Phuc Nguyen 18Phuc Nguyen 18 

Add label message in batch class

Hello Everone,
I ahve the below batch class and was wondering if ther eis a way to throw up a message to let the user know that the update is happening.  Its a batch and some of the recvords have 100+ child records so it will take a awhile for the batch classes to complete. 
public class UpdateNoticeFromAccountQueueableBatch implements Database.Batchable <sObject>, Database.Stateful{
    public List<Notice__c> noticeList = new List<Notice__c>();
    public String vatQueVatValue;
    public UpdateNoticeFromAccountQueueableBatch ( List<Notice__c> records ,String vatValueFromQue ) {
        noticeList = records;
        vatQueVatValue = vatValueFromQue;
        system.debug('noticeList value in batch' + noticeList );
        system.debug('vatQueVatValue value in batch' + vatQueVatValue );
    public List<SObject> start(Database.BatchableContext bc){
        return noticeList;
    public void execute(Database.BatchableContext bc, List<Notice__c> scope){
         List< notice>  NoticeToUpdateFromAccount = new List<Notice__c>();   
         system.debug('scope value ' + scope);
         system.debug('vatQueVatValue value batch' + vatQueVatValue);
             For ( Notice__c noticess : scope){  
               noticess.Any_other_Lessor_Info_VAT_Number__c  = vatQueVatValue;
         Database.update(scope, false);
         ---- add label message here to notify user that batch is running?

Just don't want the user guessing what is going on.

Thanks you.
Yogendra JangidYogendra Jangid
Hello, you can consider using the finish method to send a custom notification or mail for the updates with total number of records processed or failed in the batch execution.
You can use following thread on how to send mail using finish method. https://developer.salesforce.com/forums/?id=9060G000000I1BdQAK
Hope this answers your query, if so please can you mark this as the best answerl. Thanks
Phuc Nguyen 18Phuc Nguyen 18
Thanks for the reply Yogendra.  I am trying to display a message to let the user know that the process has started. Could I use a label and display a message in teh finish method?  I am calling the batch from a nother Apex class.  if that makes any difference.