You need to sign in to do that
Don't have an account?
fiona gentry
How do i setup this batch job to execute at 6am PST Mon tuesday wed thursday
Dear gurus,
How do i setup this batch job to execute at 6am PST Mon tuesday wed thursday
Thanks,
Fiona
How do i setup this batch job to execute at 6am PST Mon tuesday wed thursday
global class CopyExecutive_RTBatch implements Database.Batchable<sObject> { global Database.QueryLocator start(Database.BatchableContext BC) { // collect the batches of records or objects to be passed to execute String query = 'select Case__c, Level_1__c, Level_2__c,Level_3__c FROM Executive_RT_Case_Type__c'; return Database.getQueryLocator(query); } global void execute(Database.BatchableContext BC, List<Executive_RT_Case_Type__c> exeList) { // process each batch of records List<Case_Type__c> listCTD = new List<Case_Type__c>(); for(Executive_RT_Case_Type__c exe : exeList) { listCTD.add(new Case_Type__c(Case__c=exe.Case__c,Level_1__c=exe.Level_1__c,Level_2__c=exe.Level_2__c,Level_3__c=exe.Level_3__c)); //System.debug('Executive_RT Case No is =====>' +Case__c); } try { insExecutive_RT listCTD; } catch(Exception e) { System.debug(e); } } global void finish(Database.BatchableContext BC) { // execute any post-processing operations } }
Thanks,
Fiona
global class scheduledBatchable implements Schedulable {
global void execute(SchedulableContext sc) {
batchable b = new batchable(); // your batch class
database.executebatch(b);
}
}
You can set it to run via the point and click ui or with apex code like this:
scheduledBatchable b = new scheduledBatchable();
String sch = '20 30 8 10 2 ?'; // This is just like a regular cron job
system.schedule('Job Name', sch, b);
This blog is good to learn Cron expression.
http://sanjaal.com/java/558/cron-expressions/list-of-sample-cron-expressions-to-define-simple-and-complex-scheduling/
\\
For further reference, you can check this developer's discussion too (https://salesforce.stackexchange.com/questions/133871/cron-to-schedule-batch-class-to-run-everyday-at-10pm).
I hope you find the above information is helpful. If it does, please mark as Best Answer to help others too.
Thanks.
All Answers
global class scheduledBatchable implements Schedulable {
global void execute(SchedulableContext sc) {
batchable b = new batchable(); // your batch class
database.executebatch(b);
}
}
You can set it to run via the point and click ui or with apex code like this:
scheduledBatchable b = new scheduledBatchable();
String sch = '20 30 8 10 2 ?'; // This is just like a regular cron job
system.schedule('Job Name', sch, b);
This blog is good to learn Cron expression.
http://sanjaal.com/java/558/cron-expressions/list-of-sample-cron-expressions-to-define-simple-and-complex-scheduling/
\\
For further reference, you can check this developer's discussion too (https://salesforce.stackexchange.com/questions/133871/cron-to-schedule-batch-class-to-run-everyday-at-10pm).
I hope you find the above information is helpful. If it does, please mark as Best Answer to help others too.
Thanks.
code is below