You need to sign in to do that
Don't have an account?
KSKumaar
As in the above pic shows, I don't want to display the Standard error message which i rounded in pic. How can i make disable it? I want to display only the message what we used generally in
I can make this possible by using if - else condition (Please see the code which provided), but i want get it through using try - catch blocks only. And also please tell me that how we are getting Required fields are missing: [Account Name] message. Is that system validation rule or any other error message?
You can also see the code which i have used.
Thanks in advance.
KS Kumaar
Help needed in Exception class : Required fields are missing: [Account Name]
As in the above pic shows, I don't want to display the Standard error message which i rounded in pic. How can i make disable it? I want to display only the message what we used generally in
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.error,'Error Message'));
I can make this possible by using if - else condition (Please see the code which provided), but i want get it through using try - catch blocks only. And also please tell me that how we are getting Required fields are missing: [Account Name] message. Is that system validation rule or any other error message?
You can also see the code which i have used.
public void comittedResult() { try{ aOne=[select id,name,phone,Industry from Account where ID=:accid]; /* if (String.isBlank(accName)){ ApexPages.addMessage(new ApexPages.message(ApexPages.severity.error,'Please enter account name')); }//!(accPhone.isNumeric()) else if(!(pattern.matches('[0-9]+',accPhone))){ ApexPages.addMessage(new ApexPages.message(ApexPages.severity.error,'Please enter correct phone number')); } else {*/ aOne.name = accName; aOne.phone = accPhone; update aOne; displayPopup = false; reflectRecords(); // } }catch(DMLException e){ ApexPages.addMessage(new ApexPages.message(ApexPages.severity.error,'Please enter Name')); } }
Thanks in advance.
KS Kumaar
The above message is standard by salesforce. If you don't want this message then you should use "required=false".
Try below code to understand this :
Thanks.
There is a bug in above my posted apex code plz use below code :
Thanks.
We have one alternate.
Steps
Step 1:In vf page,First use required = false for that required field so that custom error messages will be displayed.
Step 2:Use sample code below to make that field required
<apex:outputPanel layout="block" style="float: left">
<apex:outputPanel >
<div class="requiredInput"><div class="requiredBlock"/>
<apex:inputField value="{!acc.name}" required="false" />
</div>
</apex:outputPanel>
</apex:outputPanel>
Go through the example in the link below.Hope it helps you.
http://salesforceglobe4u.blogspot.in/2016/08/how-to-override-standard-required-field.html
Let me know if you need any further help...