6

Which object stores the files (not attachments)? I'm looking to access this via a trigger.

Is it possible to add a field to this document/file objects?

2 Answers 2

14
  • The actual "content" of the file is saved as a ContentVersion
  • ContentVersion can have custom fields
  • ContentVersion is a child of ContentDocument - an object implicitly created by SFDC when the first ContentVersion is created for that file. Subsequent file versions are save as the 2nd, 3rd, ... children of ContentDocument You can think of ContentDocument as a 'header' for all of the versions of that document.
  • ContentDocument (and thus, the latest ContentVersion) is connected to the target object from whence the original file was uploaded via ContentDocumentLink (e.g. a link between Opportunity and ContentDocument)
4
  • Where is the body blob of the file stored? This way I can upload it to an external site?
    – tjcinnamon
    Commented Jul 13, 2017 at 2:17
  • 3
    @tjcinnamon - see ContentVersion.VersionData
    – cropredy
    Commented Jul 13, 2017 at 22:48
  • Perfect! Thanks much! I may need to figure out how to turn this into a binary stream but that's a different question :)
    – tjcinnamon
    Commented Jul 13, 2017 at 23:21
  • @tjcinnamon - glad this helped; as a service to the Community, you should mark the answer as accepted (check mark) so others upon searching know the question was, in fact, answered.
    – cropredy
    Commented Jun 3 at 21:16
6

ContentDocument is the object and ContentDocumentLink is the object that connects that file to a given record.

You cannot add custom fields to either of those two objects.

4
  • dang! I was hoping to add a long text area to help index these documents. Is there a different object that indexes these?
    – tjcinnamon
    Commented Dec 19, 2016 at 19:56
  • A better question would have been, "where does is the data of indexed documents stored"?
    – tjcinnamon
    Commented Dec 19, 2016 at 20:00
  • 1
    I'm not 100% sure but I believe it would be under ContentVersion Commented Dec 19, 2016 at 20:09
  • I'm looking that ContentDocument in the workbench and doing a SOQL query on the id and it says there's none
    – tjcinnamon
    Commented Dec 19, 2016 at 20:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .