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
raorao 

Adding logic to the save button for any SObject(Account,Contact, etc.,)

I want to add my own logic to the existing save button functionality.  I have task like, after saving the record I want redirect to another page. 
Scenario:  When we create a contact from account page, after saving the contact we will be redirected to newly created contact screen. But I want it to redirect to contact's account screen.
 
any kind of help is appreciated.
tmatthiesentmatthiesen

You cannot override the UI  Save button within a trigger.(You can validate the data in a before trigger and return a custom error to the edit page - but if the save is successful, you are redirected to the sobject detail page.)

In order to support this requirement, you will need to override the save button - which can only be done in a Visualforce page/Visualforce controller.  You can extend the standard Contact controller or create a custom controller to support this functionality.  You may want to re-post this to the Visualforce forum.