Apex · Salesforce · Visualforce

How to Display Error/Information messages in Visualforce Pages

Many case user want to display multiple error/warning/information message in the UI(Visualforce Page).  Please find below sample code

Apex Code :

ApexPages.addmessage(new ApexPages.message(ApexPages.Severity.Info, 'Please fill all manfaroty fields.'));
ApexPages.addmessage(new ApexPages.message(ApexPages.Severity.Error, 'Name is manfatory.'));
ApexPages.addmessage(new ApexPages.message(ApexPages.Severity.WARNING, 'Need more information in order to process your file.'));

Visualforce Page:


Note : you can use this logic for debugging code also

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s