I need to run a scheduled batch out of schedule. It has been working every day perfectly for months.
I went to try to run it in Execute Anonymous but I get the error:
Method does not exist or incorrect signature void format string from the type anon
Id batchJobId = Database.executeBatch(Update_IC_CampaignBatch(),200);
system.debug(' \n SEAN DEBUG = '+batchJobId);
This is the batch:
GLOBAL CLASS Update_IC_CampaignBatch implements Database.Batchable <SObject> {
GLOBAL Database.queryLocator start(Database.BatchableContext ctx) {
String lsStatus = 'ICReady';
string query = 'SELECT id,Name from Lead WHERE status=:lsStatus' ;
RETURN database.getQueryLocator(query);
}
GLOBAL VOID execute(Database.BatchableContext BC, List <Lead> scope) {
Set<ID> leadIDs= new Set<ID>();
for(Lead l: scope){
leadIDs.add(l.id);
}
system.debug('LeadIDs===>'+LeadIDs);
Set<ID> campaignIDs = new Set<ID>();
for(CampaignMember cm : [SELECT CampaignID, LeadID, Status FROM CampaignMember WHERE LeadID IN : leadIDs]){
campaignIDs.add(cm.CampaignID);
}
list<Campaign> listCampaign = new list<Campaign>();
for(Campaign c : [select Id, Status, Name, Parent.Name from Campaign where Id IN : campaignIDs ]){
if(c.Name.left(11) == 'IC Campaign'){
c.Status = 'IC Daily Campaign Ready';
}
else{
c.Status = c.Parent.Name + ' Campaign Ready';
}
listCampaign.add(c);
}
update listCampaign;
}
GLOBAL VOID finish(Database.BatchableContext BC) {
}
}
Best Answer
You are missing to create the instance of the class using
new
keyword.It should be: