4

I have created a trigger which fires only after insert, update & delete on opportunityLineItems. I am checking if custom setting values does not exists then generate error. It was working till last week but its not working now.

Snippet of code:

Apex Code API Version: 28

   for(OpportunityLineItem record : newList){
        record.addError('No setting exists');
   }

Do anyone knows if salesforce changes anything in this context? I am not able to find? Or I am doing something wrong.

I know as per Apex documentation 36 Version which says: Use of addError(messsageString)on Trigger.new in before insert and before update triggers, and on Trigger.old in before delete triggers, the error message is displayed in the application interface.

I am highlighting this : It was working last 1 week ago on after triggers.

Any help appreciate!

  • Now its not showing the error even if the custom setting is absent ? – karthikselva Feb 24 '16 at 10:44
  • Yes, previously till last week ago it was working. – Ajay Gupta Feb 24 '16 at 10:45
  • I would be surprised if this is broken. Can you confirm that you are testing with default layout that would report the error or if testing with Visualforce that you do have an apex:pageMessages in your page? – Keith C Feb 24 '16 at 12:37
  • 1
    @Keith C Default Standard Layout not VFPage. – Ajay Gupta Feb 24 '16 at 12:49
  • 1
    The doc is in error - if you use addError() in an after insert/update trigger context, the error does display on the standard user interface. I've posted doc feedback on this – cropredy Feb 25 '16 at 18:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.