0

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) {
    }
}
4

You are missing to create the instance of the class using new keyword.

Id batchJobId = Database.executeBatch(Update_IC_CampaignBatch(),200); // missing new

It should be:

Id batchJobId = Database.executeBatch(new Update_IC_CampaignBatch(),200);
| improve this answer | |
1

Update_IC_CampaignBatch batch1 = new Update_IC_CampaignBatch(); Database.executeBatch(batch1);

| improve this answer | |
  • While this does provide an answer but you may like to add more details to this highlighting the original issue vs. how to fix this. – Jayant Das Apr 5 '19 at 15:38
  • Sorry for a loosely typed answer. I'm new in this form, but I got the point. Thanks for the tip. – Ghosty May 2 '19 at 14:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.