I get this error when I run the below code:
Method does not exist or incorrect signature:
void schedule(String, String, PotentialCustomer)
from the typeSystem
Code:
global class PotentialCustomer implements Database.Batchable<sObject>{
global string query;
global Database.QueryLocator start(Database.BatchableContext bc)
{
query = 'select Id,Name from Potential_Customer__c where \'Service__c = 3G\'';
system.debug('----list of records' + query);
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext bc , list<Potential_Customer__c> scope)
{
list<New_Campaign__c> temp = new list<New_Campaign__c>();
for(Potential_Customer__c plist : scope)
{
New_Campaign__c nc = new New_Campaign__c();
nc.Test__c = Potential_Customer__c.Id;
nc.Name = Potential_Customer__c.Name;
temp.add(nc);
}
insert temp;
}
In Anonymous :
PotentialCustomer pc = new PotentialCustomer();
String jobId = System.schedule('jobName', '0 5 * * * ?',pc);
Best Answer
The
system.schedule
method only accepts a class instance which implementsSchedulable
as its third argument. It's most efficient to just include this implementation detail on your batch itself.Please note you do not need the
global
access modifier for batches/scheduled jobs. Thepublic
access modifier will suffice.