You need to sign in to do that
Don't have an account?
Giancarlo Amati
Email alerts for Apex Batch jobs - how to?
Hi Team,
I'm reviewing an Apex Batch job that failed overnight. I would like to update the email address that it sends in case of failure. I cannot figure out where this is built, but I've found this code in the Apex Class. There is a function called 'Label.BatchJobMonitors.split(';')' but I cannot find the definition. The 'toAddresses' is build based on that.
Any help?
Thank you
I'm reviewing an Apex Batch job that failed overnight. I would like to update the email address that it sends in case of failure. I cannot figure out where this is built, but I've found this code in the Apex Class. There is a function called 'Label.BatchJobMonitors.split(';')' but I cannot find the definition. The 'toAddresses' is build based on that.
Any help?
Thank you
String status = (String.isEmpty(job.Status)) ? '' : job.Status; status = status.toLowerCase(); ApexClass ac = [SELECT Id, Name FROM ApexClass WHERE Id =: job.ApexClassID]; String className = ac.Name; Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); String[] toAddresses = Label.BatchJobMonitors.split(';'); mail.setToAddresses(toAddresses); mail.setSubject(subject);
This is very simple there is custom label "BatchJobMonitors" which you can look like this (Setup > Quick Find > Custom label). In this label some emails id are added with semicolon for example : 'abc@test.com;xyz@abc.com'. and when this label split on ';' semicolon then it will automatically converted into string array.
Please let me know if need more information.
Thanks
Hemant
All Answers
This is very simple there is custom label "BatchJobMonitors" which you can look like this (Setup > Quick Find > Custom label). In this label some emails id are added with semicolon for example : 'abc@test.com;xyz@abc.com'. and when this label split on ';' semicolon then it will automatically converted into string array.
Please let me know if need more information.
Thanks
Hemant
Thank you.
GC