I'm trying to query a list of ContentDocumentLinks based on a set of RelatedEntityIDs, in this case Opportunities. The code looks like this:
List<Opportunity> oppList = [SELECT id, ownerid, Name FROM Opportunity WHERE Stalled__c = FALSE AND Dead__c = FALSE AND StageName != 'Closed Won' AND StageName != 'Closed Lost' AND StageName != 'Referred' ]; //Create a map and a set for later use Map<Id,Opportunity> omap = new Map<Id,Opportunity>(oppList); Set<Id> oset = omap.keyset(); //Get all the note/opportunity ids that are linked to the relevant opportunities List<ContentDocumentLink> noteLinkList = [SELECT ContentDocumentId, LinkedEntityID FROM ContentDocumentLink WHERE LinkedEntityID IN :oset];
The error I'm receiving is:
"System.QueryException: Implementation restriction: ContentDocumentLink requires a filter by a single Id on ContentDocumentId or LinkedEntityId using the equals operator or multiple Id's using the IN operator."
I can't figure out what I'm doing wrong. I tried a lot of different things (for example, using a set of IDs instead of a list) per this link: ContentDocumentLink filter error on ContentDocumentID using IN clause but nothing has worked and the same error results. Please help!