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

1
  • A set is not an Iterable. Convert it to a list
    – Eric
    Feb 20, 2017 at 23:19

1 Answer 1

3

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

Return New List<Id>(OriginalIds);
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .