2

I have a map of sets containing ids -

Map<String,Set<Id>> caseIdsByFlag = new Map<String,Set<Id>>();

& I'm trying to access the values in the map's sets in an SOQL query

List<CaseMilestone> caseMilestones = [SELECT Id, CompletionDate
                                        FROM CaseMilestone
                                       WHERE CaseId IN :caseIdsByFlag.values()];

But that's causing an error

Invalid bind expression type of Set for column of type Id

Is it possible to access the values from a map of sets in an SOQL query?

1 Answer 1

6

You need to first combine all the Set<Id> into one Set<Id> in Apex code:

Set<Id> allCaseIds = new Set<Id>();
for (Set<Id> ids : caseIdsByFlag.values()) {
    allCaseIds.addAll(ids);
}

... WHERE CaseId IN :allCaseIds ...
0

You must log in to answer this question.

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