You need to sign in to do that
Don't have an account?
Error:In Apex Message
try{
Integer countOrg=[Select count() from FTP_Details__c ft where ft.Organization__c=:details.Organization__c];
if(countOrg>0){
throw new ValidationException('Organization '+details.Organization__c+' exists in DataBase');
}
FTP_Details__c ftpSave=new FTP_Details__c();
ftpSave.Language__c=details.Language__c;
ftpSave.Organization__c=details.Organization__c;
ftpSave.Email__c=details.Email__c;
insert ftpSave;
id=ftpSave.Id;
}catch(ValidationException e){
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.severity.ERROR,
'Error retrieving competitive wins: ' + e.getMessage());
ApexPages.addMessage(myMsg);
System.debug('Error is======'+e.getMessage());
return null;
}
String newPageUrl = '/apex/SetUpTab?userId='+id;
PageReference newPage = new PageReference(newPageUrl);
newPage.setRedirect(true);
return newPage;
}
VisualForce page code:
<apex:form >
<apex:pageBlock >
<apex:pageblockButtons >
<apex:commandButton action="{!saveAndNext}" value="Save & Next" />
<apex:commandButton action="{!cancel}" value="Cancel"/>
</apex:pageblockButtons>
<font color="red"><apex:message styleClass="error"/> </font>
<table>
<tr>
Then change your controller addMessage to
You have ApexPages.addMessage - one s
Thanks for the reply,it worked for the ValidationException mentioned in code.
But as i have mentioned all the fields in the form are mandatory,so due to <apex:messages styleClass="error"/> tag in page i get error message twice for 'Required Fields' ,one where apex messages are displayed and second below each field.
Thanks in advance.