[SalesForce] Override Standard Save button on Opportunity Object

I have the below scenario to achieve :

At the time of saving the Opportunity record, I want to invoke a webservice call to the external system. If the response of the call is greater than some value, then a opportunity record should be created else it should not be created. That is, I want to restrict the creation of the opportunity record based on the response of the webservice call.

As I understand, Salesforce can override only some specific standard buttons like New, View,Edit,Delete. However one cannot override the Save button.

Any suggestions on the approach will be useful.

Thanks..

Best Answer

You can replace the standard "New" and "Edit" pages by writing a Visualforce page and controller that uses the controller extension pattern. Then within the save method of the controller extension you can make the webservice callout and if it is successful call the standard controller's save method or otherwise output an error message.

However, this does mean replacing the layout-based standard opportunity page with your own hard-coded Visualforce page which is a step you may not want to take.

Related Topic