0

So I've seen related questions to this about triggers not firing on ContentDocument, however my trigger is firing - just before the record is saved.

I am trying to make an After Insert Trigger on ContentDocument so when a "ContentNote" is saved an email will fire to notify someone.

The problem I'm running into is after I click "New Note" and start typing a title or body (picture 2 where I've just typed the letter "a"), the after insert trigger will fire before the record is actually saved. (I've also tried to make a trigger on ContentVersion and the same thing is happening).

Is there a work around for this? Or at least an explanation for this behavior?

p

 enter image description here

  • 2
    By definition, a ContentDocument has to exist before a ContentVersion can exist; the last step in the chain is the insertion of the ContentDocumentLink and you should consider the trigger on that object – cropredy Dec 6 '19 at 18:57
  • @cropredy I tried a trigger on ContentDocumentLink and it is still firing before the record is actually saved – MMeadows Dec 10 '19 at 14:39
0

Full disclosure, I've never dealt with Content Notes or the component in which you're using to add Content Notes, but...

It looks like it might be drafting the content note record. At the time of the ContentVersion trigger, does a saved version of the ContentNote which looks up to the ContentVersion exist?

Another way to check is to fill out some notes, wait for a few seconds, then either reload the page or visit another page then return. If the notes are still there, the content is drafted.

| improve this answer | |
0

Well it looks like there is no work around for this at the time of writing this, so I made a new field on the Parent object that is updated whenever a contentNote is added. It's a hacky fix but works to solve the problem.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.