+ Start a Discussion

how to handle the exception in Order object trigger updating Opportunities

Trigger testOrder on Order (after insert,after update,after delete)
update newopplist //newopplist is list of opportunities
How to handle  the exception on  update newopplist and throw customize error message

Chandra Sekhar CH N VChandra Sekhar CH N V
include the required code inside a try catch block and use .addError() method to throw error message
Amit Chaudhary 8Amit Chaudhary 8
Please check below post for Trigger. I hope that will help you .

If you want to handle the Exception in Trigger . Then please follow below code.

Triggers can be used to prevent DML operations from occurring by calling the addError() method on a record or field. When used on Trigger.new records in insert and update triggers, and on Trigger.old records in delete triggers, the custom error message is displayed in the application interface and logged
     //Your code here
} catch (ListException e) {
     //Optional catch of a specific exception type
     //Specific exception handling code here
} catch (Exception e) {
     //Generic exception handling code here
} finally {
     //optional finally block
     //code to run whether there is an exception or not
An Introduction to Exception Handling

Please let us know if this will help you

Amit Chaudhary