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
pen spen s 

Urgent need help.

ApexPages.addmessage not displaying when called from Custom Button in vf page, but error is displaying in debug logs . How to acheive this
FARSANA PSFARSANA PS
Hai Pen,

Include <apex:pageMessages /> in your vf page  and ensure that it is rerender after the method call.

Try this eg:
 
VF Page
<apex:page controller="displayMessage"> 
<apex:form id="frmid">
  <apex:pageMessages ></apex:pageMessages> 
  <apex:outputText value="Enter Name : "/> <apex:inputField value="{!Acc.Name}"/><br/><br/><br/>
  <apex:commandButton value="Submit" action="{!Submit}" rerender="frmid" />
</apex:form>
</apex:page>

Apex Controller:
public class displayMessage {
    public Account Acc{get;set;}
    public displayMessage()
    {
        Acc = new Account();
    }
    public PageReference Submit() {
             if(Acc.Name == null)
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'Please enter name!!!'));
        return null;
    }
}


Hope this helps...