When you create a new enhanced Note in the UI, it creates a ContentNote and a ContentDocument record. Does anyone know the creation order of the records? Client wants me to write a trigger for the enhanced Note, and triggers are allowed only for ContentDocument, not ContentNote.
Disregard my ill-informed comment to your OP
ContentNote is saved with key prefix
069 which is a
ContentDocument is the parent of
ContentVersion (key prefix of
You can think of the
ContentDocument as the header and ContentVersion as the actual "note" -- with multiple versions supported. As you edit the Note and click Save, a new
ContentVersion is created - but under the same
ContentNotes are typically added as children to some Object (like
Opportunity), the relationship between the ContentNote (i.e.
ContentDocument) and the Account or Opportunity is handled via a
So, what happens first when the Note is first saved?
ContentVersionis created (trigger possible)
ContentDocumentis created (happens automatically when the first ContentVersion is saved). Trigger is also possible although it is not clear to me if you'll get control when this object is initially inserted via the side effect of #1
ContentDocumentLinkis inserted - the link(junction) between the Account (or Opportunity or ...) and
ContentDocument- trigger also possible
FYI to anyone else struggling with this as I am, this is the trigger firing order when the "New" Content Note button is clicked:
and when "Save" is clicked:
Just found this detailed post Triggers on ContentObjects.