You need to sign in to do that
Don't have an account?
suneilchetlur
Validaton rule on a custom button
Hello there,
I have a custom button on opportunity standard page which when clicked displays a visualforce page.
This button should call the page only when a couple of fields on the opportunity page are correctly populated.Say field x and y.
Now I want to have a validation rule or some error message to be displayed on clicking the button whenever x and y are not properly filled.
Note- this custom button is present only on certain opportunity record types and not all.
Any suggestions would be highly appreciated.
Thanks in advance,
Suneil
Button display are related with pagelayout so don't worry about recordType validation.
Use button onclick method with return statement for validation.
e.g.
<apex:commandbutton onclick="javascript:return validate()" action="{!save}" value="Save"/>
Hi Naishadh,
Firstly,thanks for your reply.But I am not sure how I am going to implemnt something like the example you have mentioned.I think this would be used inside the visualforce page.
But my problem is that the custom button (which after being clicked displays a visualforce page)is on the standard page and needs an error message as soon as it is clicked on the standard page before going to the visualforce page.
rergards,
Suneil
For your custom button select behavior as Execute JavaScript.
Add you logic in the page and when user click on Ok or Cancel button of your message box, open visualforce page in popup.
Sample code
showPopup();function showPopup() {if(confirm('Are you sure')) {openVfPage();}}function openVfPage() {openPopupFocusEscapePounds('/apexpages/apexcomponents.apexp', 'Help', 700, 600, 'width=700,height=600,resizable=yes,toolbar=yes,status=no,scrollbars=yes,menubar=yes,directories=no,location=no,dependant=no', false, false);return false;}