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?


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()) {

... WHERE CaseId IN :allCaseIds ...

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.