I have the following query to get the list of accounts with documents attached to them. I need to filter by opportunity StageName:

select id, (Select Id, StageName From Opportunities),(Select LinkedEntityId , ContentDocument.CreatedDate, ContentDocument.Title, ContentDocument.ContentSize, ContentDocument.Description, ContentDocument.FileExtension, ContentDocument.FileType, ContentDocument.Id, ContentDocument.ContentAssetId, ContentDocument.LatestPublishedVersion.VersionData, ContentDocument.LatestPublishedVersion.PathOnClient, ContentDocument.CreatedBy.Name 
From ContentDocumentLinks)
from Account 

id IN (select AccountId from Opportunity where StageName IN ('Admitted','Discharged','Inactive','Inquiry')) and
 id IN(select LinkedEntityId from ContentDocumentLink)

The query is pulling all the accounts with and without documents. How can I add the condition to get only the ones with documents and keep the Opportunity information? the last line is the condition, but I get the error bellow:

Entity 'ContentDocumentLink' is not supported for semi join inner selects


You must log in to answer this question.

Browse other questions tagged .