You need to sign in to do that
Don't have an account?
Saswat Mohanty
single email notification for all batch class job finish
Hi all,
We have 2 batch classes developed on contact and on one custom object. If everytime these 2 objects are updated, the batch class runs showing the progress which we are showing in a visualforce page.
Also, we have designed a mail template in class so that everytime the batch jobs are finished the email will be triggered. However, we want to limit the no. of emails at regular intervals. So, how can we receive a single email at the end of the day for every batch class/job sectionwise?
We have 2 batch classes developed on contact and on one custom object. If everytime these 2 objects are updated, the batch class runs showing the progress which we are showing in a visualforce page.
Also, we have designed a mail template in class so that everytime the batch jobs are finished the email will be triggered. However, we want to limit the no. of emails at regular intervals. So, how can we receive a single email at the end of the day for every batch class/job sectionwise?
My thought on this...
-Store your update progress in contact and custom object in a seperate variable.
-Write a schedule class which will read this progress and send a mail.
-Execute this schedule class at a specific time everyday.
Best Regards,
Rahul
global class batchmailtrigger implements Schedulable{
// Execute method
global void execute(SchedulableContext SC) {
batchContactUpdate c1 = new batchContactUpdate ();
batchBrandUpdate b1 = new batchBrandUpdate ();
database.executebatch(c1,10);
database.executebatch(b1,10);
datetime nextScheduleTime = system.now().addMinutes(60);
string minute = string.valueof(nextScheduleTime.minute());
string second = string.valueof(nextScheduleTime.second ());
string cronvalue = second+' '+minute+' * * * ?' ;
string jobName = 'batchmailtrigger' +
nextScheduleTime.format('hh:mm');
batchmailtrigger p = new batchmailtrigger ();
system.schedule(jobName, cronvalue , p);
system.abortJob(sc.getTriggerId());//Aborting the Job
}
}
But I think i can put a mail template in this scheduler instaed of in batch class. However, i am thinking that I am missing the variable store.
is that true?
I am not sure if you can put below part in execute function
////
batchmailtrigger p = new batchmailtrigger ();
system.schedule(jobName, cronvalue , p);
system.abortJob(sc.getTriggerId());//Aborting the Job
////
It should be executed from Execute Ananymous Window.
Have creating fields to store progress of contact and custom object?
Also please clarify, need of below statements. Are you using batch here?
///
batchContactUpdate c1 = new batchContactUpdate ();
batchBrandUpdate b1 = new batchBrandUpdate ();
database.executebatch(c1,10);
database.executebatch(b1,10)
////
Regards,
Rahul