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
Sandy GaliSandy Gali 

Apex messages/ error messages on visualforce pages

Hi Guys,
       I built a visualforce page for Salesforce1 and want to display the validation error messages on the screen. I am not able to show any error messages/alerts on the screen and as a reason user would not know if the transaction was successful or not.

My VF page looks something like this:

<apex:page standardController="Account" standardStylesheets="false" sidebar="false" applyBodyTag="false" docType="html-5.0" id="mypage">
<apex:pageMessages />
<apex:form >
<apex:pageBlock >
Name: <apex:inputField id="field1" value="{!Account.Start_Time__c}"/>
</apex:pageBlock>
    
</apex:form>        
<script type='text/javascript' src='/canvas/sdk/js/publisher.js'></script>
<script> 
    
    Sfdc.canvas.publisher.subscribe({name: "publisher.showPanel",
        onData:function(e) {
            Sfdc.canvas.publisher.publish({name:"publisher.setValidForSubmit", payload:"true"});
    }});
    Sfdc.canvas.publisher.subscribe({ name: "publisher.post",
        onData: function(e) {
        alert("remote action here");
         getRemoteAccount();     
       Sfdc.canvas.publisher.publish({ name: "publisher.close",
       payload:{ refresh:"true" }});

    }});
    
        function getRemoteAccount() {
            // retrieve values here from the form


           Visualforce.remoting.Manager.invokeAction(  
            '{!$RemoteAction.<apex class>.<method name>}',
             params,
             function(result, event){
                if (event.status) {
                    alert("Inside event"); 
                  
                } else if (event.type === 'exception') {
                     alert(event.message);
                } else {
                      var  msg = result;
                      alert(msg);
                }
            }, 
            {escape: true}
        );
    }
    
    </script>    
    
</apex:page>

and I have catch block in my controller which does Apexpages.addMessage('message');

Any idea on how to display error messages when you are using submit in salesforce1 mobile and not the standard button