You need to sign in to do that
Don't have an account?
Validation message displaying twice
Hi All,
I have some long text area fields in my VF page which is using Standard controller and extension.
I am using Standard save method in the action for Saving the record.
The long text area fields have character limit of 10000.
When I enter more than 10000 characters in the field and click Save, I am getting the following error message twice
"You can't use more than 10,000 characters"
I am not using pagemessage tag and there is no validation rule also.
This is happening in the sandbox instance which was recently refreshed with the new winter release 11.
Initially I thought there is some problem in the controller. So I tried to have only one field in the page with only Standardcontroller and no extension. Still it displays the error message twice.
Following is the code I am having in my VF page.
<apex:page standardController="Case" apiVersion="20"> <apex:form > <apex:pageBlock > <apex:pageBlockSection title="Problem Description Notes" id="pbs1" columns="1"> <apex:inputField value="{!Case.Problem_Description__c}" style="width:300px"/> </apex:pageBlockSection> <apex:commandButton value="UpdateCase" action="{!Save}"/> </apex:pageBlock> </apex:form> </apex:page>
I am not getting what is the mistake here.
I tried the same thing in my developer instance which is still not refreshed with the new release.
There the error message is displayed only once.
So, I am not getting if this is a new release issue.
Please let me know your suggestions.
Thanks
Arvind
Hi Arvind,
Hi have been through this always and then i find out a way to get through this :smileyvery-happy: . see code with explanation.
Salesforce Documentation says,
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.severity, summary, detail);
**where ApexPages.severity is the enum that is determines how severe a message is, summary is the String used to summarize the message, and detail is the String used to provide more detailed information about the error.
http://boards.developerforce.com/t5/Visualforce-Development/Validation-message-displaying-twice/m-p/206193#M28392
So according to salesforce there should be two parameters summary and detail. but if you skip the detail parameter, then it will display summary twice (not mentioned in documentation).
This expression display error message twice
apexpages.addMessage(new ApexPages.Message(ApexPages.Severity.info, 'YOUR ERROR MESSAGE' )) ;
This expression display error message only once :smileywink:
apexpages.addMessage(new ApexPages.Message(ApexPages.Severity.info, 'YOUR ERROR MESSAGE' , '' )) ;
I hope this will help you also.
A Karim Soomro
Software Engineer & Cloud Consultant
Force.com Certified Developer.
For Example,
Another solution I found that works. If you are using the <apex:pageMessages> tag in your visualforce page to display error messages, it has a showDetail attribute. If you set this to False, then you DON'T need to put a blank detail parameter in your controller. See code below
Visualforce page
Controller/Extension