Feb 242015

Salesforce – How to show different error messages in Apex / Visualforce?

When we build custom Visualforce page, there are times we want to send some error message to user saying that something went wrong or additional data is required. Other time we want just inform him, that process bas been successfully ended.

We can do this by showing different types Apex page message severities. To do this, just use one of the following:


ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Fatal, 'ApexPages.Severity.FATAL'));


ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, 'ApexPages.Severity.ERROR'));


ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Warning, 'ApexPages.Severity.WARNING'));


ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Confirm, 'ApexPages.Severity.CONFIRM'));


ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info, 'ApexPages.Severity.INFO'));

and you will get one of these pretty images.


Tagged with , , , , , 0 comments

Leave a Reply

Your email address will not be published. Please enter your name, email and a comment.