SOQL Subquery – Getting Cases that have updated ContentDocumentLinks (Attachments)

What you cannot do is filter down the Cases returned in the 1st query on only Cases that have a modified ContentDocumentLink.

E.g. this will result in an error:

select id from Case where Id in (select linkedentityId from contentdocumentlink where SystemModstamp  > 2022-02-22T13:32:47Z)

Entity ‘contentdocumentlink’ is not supported for semi join inner

What you can do is fetch the updated ContentDocumentLinks while fetching the Cases (but you will also get Cases that do not have an updated ContentDocumentLink):

select id, (select id,SystemModstamp   from Contentdocumentlinks where SystemModstamp  > 2022-02-22T13:32:47Z) from Case

You can then loop through the Case.ContentDocumentLinks list in your apex code to find out if there are any updated ContentDocumentLinks.

The key here is to find the right relationship name from which you can query child ContentDocumentLinks from the parent Case object. In this case (pun intended) ContentDocumentLinks

Read more here: Source link