function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Uri MaslovskyUri Maslovsky 

how to download all files attached to a give Case object using PHP?

Hi, I'd like to ask how can I fetch all files attached to a Case object. I'm using Lightning mode and scripting in PHP.

I don't seem to find where exactly ContentVersion, ContentDocument and ContentDocumentLink are somehow relates to Case object.

I'm looking for a way to locate and download all attachments based on a query where my input is Case number or case ID

Thanks in advance

Uri 
ANUTEJANUTEJ (Salesforce Developers) 
Hi Uri,

As stated in this link [ https://developer.salesforce.com/forums/?id=9060G000000BgW6QAK ] you could use a soql to query all the files attached to cases and you could add case id filter to get files for a particular case.

>> SELECT ContentDocumentId, LinkedEntityId  FROM ContentDocumentLink where LinkedEntityId in ( SELECT Id FROM Case ) and LinkedEntity.Type='Case'


I hope this helps and in case if you found this useful can you please choose this as best answer so that it can be used by others in the future.

Regards,
Anutej