function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
vinayakamurthyvinayakamurthy 

Error messages

how can i get an visualforce error messages in a variable and can store that???

vbsvbs
Use the following:
ApexPages.hasMessages() to find if any errors exist on the page AND
ApexPages.Message[] apxMsg = ApexPages.getMessages();

souvik9086souvik9086

You can check Like the following

 

ApexPages.getMessages();

 

You can also get the exeptions through try-catch.

 

If you want to add new message through controller then like the following

 

Controller

public String pageMsg{get;set;}

pageMsg = 'Please select at least one field for Assignment.';
ApexPages.addMessage( new ApexPages.Message(ApexPages.Severity.ERROR,pageMsg));

 

Page

<apex:outputPanel rendered="{!pageMsg != NULL}">
<apex:pagemessages />
</apex:outputPanel>

 

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks