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
More Development questions
- What is an Apex Trigger in Salesforce and when should you use it over Flows?
- What is the difference between before triggers and after triggers?
- Explain all Trigger context variables (isInsert, isUpdate, isDelete, isUndelete, isBefore, isAfter, isExecuting, size, operationType).
- What is the difference between Trigger.new and Trigger.old?
- In which trigger events are Trigger.new and Trigger.newMap available?
- In which trigger events are Trigger.old and Trigger.oldMap available?