1

I want to filter opportunities to grab specific set of campaigns in start method itself and pass the filtered list to the execute. I am thinking of not to use additional query in start method using Database.getQueryLocator since I already have the entire list coming in constructor. I am planning to use Iterable as return in start method but getting following error "Return value must be of type: Iterable"

Code:

public Iterable<sObject> start(Database.BatchableContext bc){
        for(Opportunity Opp: newList){            
            //Filter incoming opportunities and grab campaignIds of the sccess opportunities into set "OriginalCampaignIds"
        }        
    return OriginalCampaignIds;
}

Tried below codes:

public List<Id> start(Database.BatchableContext bc){
        for(Opportunity Opp: newList){            
            //Filter incoming opportunities and grab campaignIds of the sccess opportunities into set "OriginalCampaignIds"
        }    
    }        
    return new List<Id>(OriginalCampaignIds);
}

Error: Class must implement the global interface method: Iterable start(Database.BatchableContext) from Database.Batchable

Another Try:

public Iterable<Id> start(Database.BatchableContext bc){
        for(Opportunity Opp: newList){            
            //Filter incoming opportunities and grab campaignIds of the sccess opportunities into set "OriginalCampaignIds"
        }       
    return new List<Id>(OriginalCampaignIds);
}

Same error as above

  • A set is not an Iterable. Convert it to a list – Eric Feb 20 '17 at 23:19
3

A set is not an Iterable, covert to a list:

Return New List<Id>(OriginalIds);

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.