You need to sign in to do that
Don't have an account?

How to display the custom error message using visualforce page
i want to display the custom error message .how to solve the above solution please give any ideas.
You need to sign in to do that
Don't have an account?
We can implement this requirement by creating new instance of ApexPages.message and then adding message to Apexpages using ApexPages.addmessage. Then displaying these messages in visualforce page.
We can add 5 different types of message in Visualforce Page. In the example below, we are showing 5 input fields of account. We have added a button on visualforce page. Different type of message will be shown on visualforce page if we will keep any field blank.
Please follow the below link for more info
http://www.sfdcpoint.com/salesforce/show-error-message-visualforce-page/
http://sfdcsrini.blogspot.com/2014/12/show-error-message-in-visualforce-page.html
Best Regards
NagaKiran
Please try below code. Let us know if it helps.
can you please give me the example of positive test cases in salesforce
Here is an example.
Let us know if it helps.
Hi, Ashish_Sharma_DEVSFDC
How to throw the custom error message using custom object and don't fill the required fields and click save it will display custom error message .how to find this issue give some ideas.
Please try below code and let us know if it helps you.
Hi, Ashish_Sharma_DEVSFDC
can you please give me the example of how to override the standard error messages in visualforce page.
my requirement you must have one require field,when i click the save (don't fill the values) it will show custom error message.please give one example of that code
Hi nishad basha 7
override the standard error messages in vf page
<style>
.errorM4 .msgIcon, .errorSmall { background-image: url(/img/samples/flag_red.gif) !important; }
.myCustomMessage .message { background: none !important; border: none !important; }
</style>
<apex:outputPanel styleClass="myCustomMessage">
<apex:pageMessage severity="error" strength="1" summary="Your ErrorMessage" />
</apex:outputPanel>
On button write actionfunction like below:
<apex:commandButton onclick="return checkRequired();" value="Save" oncomplete="refreshPage()"/>
<apex:actionfunction name="save" action="{!Save1}"/> </apex:pageblockButtons>
and on Apex page write :
for(String productName : productsList ) {
if(productName == 'Test& caseRec.fieldName)
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Field should not be empty when selected');
ApexPages.addMessage(myMsg);
isError = true;
}
On button write actionfunction like below:
<apex:commandButton onclick="return checkRequired();" value="Save" oncomplete="refreshPage()"/>
<apex:actionfunction name="save" action="{!Save1}"/> </apex:pageblockButtons>
and on Apex page write :
for(String productName : productsList ) {
if(productName == 'Test' && caseRec.fieldName == 'Test')
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Field should not be empty when selected');
ApexPages.addMessage(myMsg);
isError = true;
}
Please let me know if you need any help further!!!!
Cheers
I am new sfdc.... can anyone help me please1
How to display our own error message in the vf page . when the field is required or mandatory!.... through the controller .
However, i am not able to display the validation error message on my standard page layout(where the button is actually placed) which we are trying to validate on the apex controller class.
Example :
Controller Code
if(acc.phone == '' || acc.phone == null) ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please enter Account phone'));
VisualForce Code
<apex:pageMessages id="showmsg"></apex:pageMessages>
Is there anyway we can display the validation error message from my controller code to the standard page layout or even custom VF page in some cases.
Thanks in advance and appreciate your help.
Venkatesh
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'You Can Not Add This number'));
.And for Visual force page:
<apex:commandButton value="Save" action="{!submit}" reRender="mid" ></apex:commandButton>
<apex:pageMessages id="mid" />
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}
if(("{!PCCA_Certification__c.PCCA_Status__c}" =='Draft') && ("{!PCCA_Certification__c.PCCA_Delete_Flag__c}" == false ) && ("{!$Profile.Name}" =='System Administrator')){
var result = sforce.apex.execute("PCCA_CertificateValidation","CertificateValidation",{CertificationId:"{!PCCA_Certification__c.Id}"});
alert(result);
location.reload(true);
}
else{
alert('You can only validate draft Certification');
}