Salesforce trigger hell-1
Problem Many a time we see that the errors added by trigger's, are being shown to user in the below format, which are not user friendly and user's complain about that. Error: Invalid Data. Review all error messages below to correct your data. Apex trigger validateLastname caused an unexpected exception, contact your administrator: validateLastname: execution of BeforeInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, no child allowed: Trigger.validateLastname: line 6, column 1 Root cause Whenever error with the line number is shown to user, you can be sure that this is un-handled exception. And it comes basically when you have fired another DML inside any trigger, and that DML is failed. Let's understand this by scenario. Scenario Let's assume that User is trying to save a record of OBJ1 from User interface. and you have written a trigger on OBJ1, which on certain cond...