What is the sample code to schedule class in salesforce
I'll be working on creating a apex schedule class and I just need a pointer to start is that possible if you can have a working small sample where I can understand how the mechanics work and I have googled but not find what exactly I want and also I looked at the salesforce site https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_scheduler.htm
To schedule class in salesforce, You can take help from the below example :
Batch class :
global class BatchCreateOpportunity implements Database.batchable{
global Database.QueryLocator start(Database.BatchableContext bc){
String query = 'SELECT id from Account limit 1';
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List scope)
{
List oppList = new List();
for(Account acc : scope )
{
for(integer i=0;i
insert oppList;
}
global void finish(Database.BatchableContext BC)
{
}
}
Scheduler class :
global class schduleBatchCreateOpportunity implements Schedulable {
global void execute(SchedulableContext ctx) {
BatchCreateOpportunity p = new BatchCreateOpportunity();
database.executeBatch(p);
}
}