You need to sign in to do that
Don't have an account?
Developer.mikie.Apex.Student
Validation Errors appearing on visualforce Page please help
Hey there,
I have validation rules on my custom object service__c. Service__c, has a visualforce page for creating new services. Whenever a validation rule is triggered however, rather than the error appearing on te page in error, with no re-direction...it is re-directed to another page, which is all white, with black writing that says:
Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION
How can I make the errors appear on the visualforce page without re-direction? If it helps, I have made all the buttons custom.
I have already added <apex:pagemessages/> to the top of the page.
please Help
I have validation rules on my custom object service__c. Service__c, has a visualforce page for creating new services. Whenever a validation rule is triggered however, rather than the error appearing on te page in error, with no re-direction...it is re-directed to another page, which is all white, with black writing that says:
Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION
How can I make the errors appear on the visualforce page without re-direction? If it helps, I have made all the buttons custom.
I have already added <apex:pagemessages/> to the top of the page.
please Help
Redirect to other page only if it saves successfully
try {
insert ser;
// Send the user to the detail page for the new account.
PageReference pageRef= new PageReference('/apex/DestinyAccount?id='+ser.account__c+'&Sfdc.override=1');
pageRef.getParameters().put('tab','Destiny Services');
return pageRef;
} catch (Exception e) {
ApexPages.addMessages(e);
}
return null;
All Answers
You will have to use try catch block.
Example:
try {
// Your code here
} catch (Exception e) {
ApexPages.addMessages(e);
}
When you say my code, do you mean my entire Extension? or the button section? or just the insert line?
All it did was skip validation. Maybe I wrote it in wrong
Redirect to other page only if it saves successfully
try {
insert ser;
// Send the user to the detail page for the new account.
PageReference pageRef= new PageReference('/apex/DestinyAccount?id='+ser.account__c+'&Sfdc.override=1');
pageRef.getParameters().put('tab','Destiny Services');
return pageRef;
} catch (Exception e) {
ApexPages.addMessages(e);
}
return null;