Sorry if the format is not good, first post ever and I don't know what all the options are.
totalRecords list size is printing as NULL in the email message body, I cannot figure out why.
global class errorRecordsCleanUp_batch implements Database.Batchable<SObject> {
global Integer totalRecords;
global void execute(Database.BatchableContext BC, List<ErrorRecords__c> scope) {
List<ErrorRecords__c> errorList = new List<ErrorRecords__c>();
for(ErrorRecords__c element:scope) {
errorList.add(element);
}
try {
totalRecords = errorList.size();
System.debug('####totalRecords size: ' + totalRecords);
**//this debug statement if printing out the correct totalRecords size no problem**
}
…//rest of the class
}
global void finish(Database.BatchableContext BC) {
String body = 'Hello,<br/><br/>Batch process to delete errors records from ErrorRecords__c table has been completed. <br/><br/>' + 'Total deleted records: ' + totalRecords;
**//this string in printing totalRecords as NULL in the email message body, why is that?**
…//rest of the class
}