+ Start a Discussion

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?


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

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