I know how to query all the attachments related to the opportunity, but how to do the same for files attached. Seems like a file is a part of a content library.
-
Are these chatter files? If so, this related question should provide a solution for you.– battery.cordJun 3, 2016 at 18:50
-
No, I'm asking about Files. You can attach files using Lightning experience– Mike RavenJun 3, 2016 at 21:24
-
Solved. The file is actually a content document and could be easily obtained via foreign key: SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId = '<Opportunity or other object id here>'– Mike RavenJun 3, 2016 at 23:04
-
2Can you add your comment as an answer and mark it as best answer, as it might help other users in the future with the same question.– Jenny BJun 4, 2016 at 19:49
2 Answers
Solved. The file is actually a content document and could be easily obtained via foreign key:
SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId = '<Opportunity or other object id here>'
SELECT ContentDocumentId, linkedEntityId FROM ContentDocumentLink WHERE LinkedEntityId = "123"
ContentDocumentId = a salesforce object Id where this file is being used , linkedEntityId = id of the stored file
-
-
the query is the same. Just aadded the info about ContentDocumentId and linkedEntityId Jun 22, 2020 at 9:18