Salesforce Schedule APEX Batch Job

To test an APEX Batch job, open the Developer Console then the Anonymous Execute window. Here’s the code to run the job:

datetime thisTime = system.now().addMinutes(1); 
integer second = thisTime.second(); 
integer minute = thisTime.minute(); 
integer hour = thisTime.hour(); 
integer day = thisTime.day(); 
integer month = thisTime.month(); 
integer year = thisTime.year(); 

String timeStamp = second + ' ' + minute + ' ' + hour + ' ' + day + ' ' + month + ' ? ' + year; 

String jobId = System.schedule('Test Opportunity Contact Lookup', timeStamp, new ZD_UpdateContactOpportunityBatch());

Leave a Reply

Your email address will not be published. Required fields are marked *