Development questions

Write a SOQL query to fetch all files (ContentDocument / ContentVersion) linked to a specific Account record via ContentDocumentLink.

Files connect to records through ContentDocumentLink (LinkedEntityId is the record Id). Query the link and traverse to the ContentDocument for the file details.

soql
SELECT ContentDocumentId, ContentDocument.Title, ContentDocument.FileExtension, ContentDocument.LatestPublishedVersionId
FROM ContentDocumentLink
WHERE LinkedEntityId = :accountId

To get the file body, query ContentVersion where ContentDocumentId matches and IsLatest = true.

soqlscenariofilescontent-document