Salesforce | Display error message returned by Trigger with enter key

Author - Kiranpreet Kaur
16.01.2018
|
2 Comments
|

How to send an error message from trigger back to the layout and display it on the record detail page. You need to use addError method for this.

For example :

errorMsg=’Some of the catalog courses are not available in LMS.<br/>Please sync them to LMS first’;
for( Account account: trigger.new ){
   account.addError(errorMsg);
}

It will show on the top of the page as :

1

But we also need to add new line character to this message. For this, you need to add in the message and send extra parameter in the addError method like :

errorMsg=’Some of the catalog courses are not available in LMS.<br/>Please sync them to LMS first’;
for( Account account: trigger.new ){
   account.addError(errorMsg,false);
}

Now it will look like this :

2

Webner Solutions is a Software Development company focused on developing Insurance Agency Management Systems, Learning Management Systems and Salesforce apps. Contact us at dev@webners.com for your Insurance, eLearning and Salesforce applications.

2 responses on “Salesforce | Display error message returned by Trigger with enter key

  1. Pulkit says:

    This is not working, everywhere I see this addError() but not working.

Leave a Reply

Your email address will not be published. Required fields are marked *