function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sandip beherasandip behera 

How to override the standard save button of account object

Hi,
I had requirement to do some extra stuff  when user create a new  an account or edit an account. So I want to overrride the  standard save button .
I wnat to override the save button in apex could anyone guide me how to do that.

Thanks
Sid_CloudSid_Cloud
I dont think it is possible to change the functionality of the Save button in the Standard layout, but what can be done is creating a VF Page and using a custom controller or a controller extension for the same.
cloudSavvyProgcloudSavvyProg
Hi Sandip,

Create an extension class ,as shown in the below example,
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_extension.htm

And then you can override the save function in the extension class. code looks like below.
public PageReference save() { 
// Put your own stuff here
PageReference newPage = New PageReference('/apex/<page name you want to return>');
newPage.getParameters().put('id',ApexPages.currentPage().getParameters().get('id'));
newPage.setRedirect(true);
return newPage;
}

Some documents to help you.
https://help.salesforce.com/HTViewHelpDoc?id=links_override_considerations.htm&language=en_US

Hope this helps.

Regards,
CloudSavvyProg
cloudSavvyProgcloudSavvyProg
Hi Sandip,

If any of above solutions has resolved your issue then please mark it as solved.

Thanks,
CloudSavvyProg
shoba shobashoba shoba
Hi sandip behera

I have a requirement like yours. Have you got output. If yes can you please share your code.