+ Start a Discussion
bouscalbouscal 

Before or After? New or Old?

Need some help understanding when to use before or after triggers and new or old.  Spefically I have the following issue;
When a Case is Escalated I want to create a child Case of a different record type but only if one doesn't already exist.  this works.
* If the child Case already exists I want to update it's status (from Closed to Open).  * System.FinalException: Record is read-only:
When the child Case is closed I want to update the Parent. this works
Also, when the Child is Closed I want to update the Parent. this works.

I have the code to do all of that but I get read only errors trying to update the Child.  I have tried with many combinations of before/after new/old
Best Answer chosen by bouscal
bouscalbouscal
Issue was related to recursion, seems like understanding the specific order of execution is my next task.

All Answers

bob_buzzardbob_buzzard
After triggers will not allow you to update the trigger records, as these have been written to the database (although not yet committed).  What I don't understand is why a child record would be read only when you are processing the parent case.
bouscalbouscal
Issue was related to recursion, seems like understanding the specific order of execution is my next task.
This was selected as the best answer