[SalesForce] How to override standard Change Owner functionality

I need to add additional checkbox(Transfer open activities) to the Change Account Owner screen.

Like this

As far as I know, there is no way to edit this standard functionality so I decided to create a custom one(create new button, VF page, apex controller).

But I have faced a problem – with custom functionality I can't update records without triggering fields validation:
e.g if I set "Transfer open opportunities not owned by the existing account owner" as true, I can't update all related opportunities.

Is there a way to avoid validation rules in this case or maybe there is a special class to change account owner(like we have a class to convert lead)?

Best Answer

What kind of validation is the issue? Check in to the "immediate" attribute in VF (on command button, for example).

If that doesn't meet your needs, you can do the checkbox approach outlined by SFDC NOOB above. I would do it a little differently though :

  1. Use a custom VF page
  2. Set the check box to true when you do the insert (under proper conditions, obviously)
  3. Never expose this box on a page layout
  4. Reset the value to false (in a trigger or a 2nd update call in your controller)
Related Topic