You need to sign in to do that
Don't have an account?
ramesh
cornexepresion
system.schedule('jobNametest1111', '1,59,23,*,*,1-7', new batchschedual2());
my schedule program
global class batchschedual2 implements system.Schedulable
{
global void execute(system.SchedulableContext scontext)
{
database.executeBatch(new batchannualrevenue());
}
}
my batch program
global class batchannualrevenue implements database.Batchable<sobject>,database.stateful
{
decimal totalrevenue =0.0;
global database.QueryLocator start(database.BatchableContext bcontext)
{
return database.getQueryLocator([select id,name,annualrevenue from account where annualrevenue != null]);
}
global void execute(database.BatchableContext bcontext,list<sobject> recordstiprocess)
{
for(sobject records:recordstiprocess)
{
account accsrec = (account)records;
totalrevenue +=accsrec.annualrevenue;
}
}
global void finish(database.BatchableContext bcontext)
{
system.debug('bcontext id is========='+bcontext.getJobId());
asyncapexjob jobdetails =[select id,status,numberoferrors,totalJobItems,jobitemsprocessed,createdby.email from asyncapexjob where id =:bcontext.getJobId()];
//===========================
BatchJobNotificationsHelper.SendBatchJobStatusNotification(jobdetails, totalrevenue, 'batchannualrevenue');
}
}
Line: 1, Column: 1 System.StringException: Unexpected end of expression.
cornexepresion
system.schedule('jobNametest1111', '1,59,23,*,*,1-7', new batchschedual2());
my schedule program
global class batchschedual2 implements system.Schedulable
{
global void execute(system.SchedulableContext scontext)
{
database.executeBatch(new batchannualrevenue());
}
}
my batch program
global class batchannualrevenue implements database.Batchable<sobject>,database.stateful
{
decimal totalrevenue =0.0;
global database.QueryLocator start(database.BatchableContext bcontext)
{
return database.getQueryLocator([select id,name,annualrevenue from account where annualrevenue != null]);
}
global void execute(database.BatchableContext bcontext,list<sobject> recordstiprocess)
{
for(sobject records:recordstiprocess)
{
account accsrec = (account)records;
totalrevenue +=accsrec.annualrevenue;
}
}
global void finish(database.BatchableContext bcontext)
{
system.debug('bcontext id is========='+bcontext.getJobId());
asyncapexjob jobdetails =[select id,status,numberoferrors,totalJobItems,jobitemsprocessed,createdby.email from asyncapexjob where id =:bcontext.getJobId()];
//===========================
BatchJobNotificationsHelper.SendBatchJobStatusNotification(jobdetails, totalrevenue, 'batchannualrevenue');
}
}
Run the below code in developer console. Refer the below link.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_scheduler.htm
If this helps, Please mark it as best answer.
Thanks!!