function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MyGodItsColdMyGodItsCold 

APEX breaks Validation rule - does other processing stop?

I have an APEX trigger which under certain circumstances, breaks a Validation rule (on purpose - so the object gets listed in the error popup when the user is doing an inline mass edit on a VF enhanced list). When that happens, I also wanted to create an instance for my log file object & insert it, saying that I just broke the Validation rule.

 

Even though we are speaking of a completely different custom object, it's as if the processing stops when the Validation rule is broken & even if I have the insert of the log object instance earlier in the code - it's like the commits which were queued were not released once the Validation rule was broken.

 

Has any one come across something like this?

ahab1372ahab1372

You are right. You can read the details if you search the Apex Documentation for "Triggers and Order of Execution". After the insert operation, several things happen, one of them is Validation rules being executed. If they fail, changes are not committed to the database.

 

Not sure if there is an workaround

Nick1746323Nick1746323
I expect you could use try .. catch and possibly a rollback, to get around this.