Timeline for Attachment trigger work not persisting
Current License: CC BY-SA 4.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 2, 2019 at 10:46 | comment | added | Salesforce crm | i have added trigger and it's handler too and as Sebastian Kessel said it's my mistake to put query inside the loop but now everything is fine but stills it's throwing below error. Error: Apex trigger sales_force_crm.AttachmentTrigger caused an unexpected exception, contact your administrator: sales_force_crm.AttachmentTrigger: execution of AfterInsert caused by: System.DmlException: Update failed. First exception on row 0 with id 00P2v00001wjgixEAA; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, | |
Jul 29, 2019 at 15:50 | history | edited | Sebastian Kessel | CC BY-SA 4.0 |
added 265 characters in body
|
Jul 29, 2019 at 15:34 | comment | added | Phil W | Let us continue this discussion in chat. | |
Jul 29, 2019 at 15:33 | comment | added | Sebastian Kessel | I've seen some things in my life, dude. :-) I'm sure you've seen the same. "Assume nothing" is my motto. | |
Jul 29, 2019 at 15:33 | comment | added | Phil W | That's a fair point except the title says "Attachment trigger". | |
Jul 29, 2019 at 15:32 | comment | added | Sebastian Kessel | Now you're assuming the trigger is on the attachment object. Which I can't do. Once proper detail is provided, I will be happy to adjust my code to what the OP's scenario looks like. | |
Jul 29, 2019 at 15:31 | comment | added | Phil W | You can't update the trigger objects themselves in the after phase. You will get an exception. | |
Jul 29, 2019 at 15:31 | comment | added | Sebastian Kessel | It is most definitely not "plain wrong" if this is an "after" trigger, as stated in my answer. There could be good reasons for this and, since the OP has not provided neither context nor detail, I cannot assume that this code was meant to run in the "before" and therefore stuck as close as I can to the code that was provided. | |
Jul 29, 2019 at 15:28 | comment | added | Phil W | Note that there is an implication that the handler is called from a trigger, so the update at the end is plain wrong. What must be done is to update the attachments in the input "attaches" list instead (a DML is then not needed). Update your answer and I'll upvote it. | |
Jul 29, 2019 at 15:26 | history | answered | Sebastian Kessel | CC BY-SA 4.0 |