Find your content:

Search form

You are here

Transfer Account ownership without changing opportunity owner


Need to maintain opportunity ownership when an account owner is changed using the change owner link.

Our sales staff are creating accounts and working prospects using opportunities. Once the account is reassigned to a relationship manager, the sales staff lose ownership of their opportunities. Is there a way to stop this from happening?

The sales staff need to be opportunity owners to recieve credit and relying on someone else to give permission back to them seem counter productive.


Attribution to: Utahstew

Possible Suggestion/Solution #1

you could use a trigger to revert the ownership back in certain situations.

Attribution to: ebt

Possible Suggestion/Solution #2

Using a trigger to maintain the prior value is always an option.

Have you looked at enabling Team Selling?

I believe that's the only dependency to having the 'Keep Sales Team' option appear when you're transferring an account to a new owner which would solve your problem as long as the user doing the reassignment remembers to check the box.

Attribution to: Baxter

Possible Suggestion/Solution #3

I came up with a solution using the Account Trigger before and after updates.

Here is the helper Class handling the logic: It basically will revert the Opportunity's owner back to the old owner, for any Closed Opportunities caught up in the owner transfer.

public with sharing class blogicAccount {

    static map<id,id> beforeUpdateMap;

    public static void handleBeforeUpdate( list<Account> newAccounts){

        set<id> actIds = new set<id>();
        for(Account a : newAccounts){
        list<Opportunity> opps = [Select id, accountid, ownerid, from Opportunity where accountid in :actids];
        beforeUpdateMap=new map<id,id>();
        for(Opportunity o : opps){
            system.debug('***Opp owner on Account beforeUpdate:';

    public static void handleAfterUpdate( list<Account> newAccounts){

        set<id> actIds = new set<id>();
        for(Account a : newAccounts){
        list<Opportunity> updateOpps = new list<Opportunity>();
        list<Opportunity> opps = [Select id, isClosed, accountid, ownerid, from Opportunity where accountid in :actids];
        for(Opportunity o : opps){
            system.debug('***Opp old owner: '+beforeUpdateMap.get(o.accountid));
            system.debug('***Opp owner on Account AfterUpdate:'+o.ownerid);
            if(o.isClosed && o.ownerid != beforeUpdateMap.get(o.accountid) ){
        //SET A TRIGGER FLAG to prevent ANY and ALL triggers from firing on the Opportunity Update
        //id triggerFlags.ByPassOpptyTrigger=True
        //  and in the Opportunity Trigger, always check this flag.
        update updateOpps;


Attribution to: Joe B

Possible Suggestion/Solution #4

This is native Salesforce functionality. I don't know why they have the option to select transfer open opportunities in the UI if it's going to do it anyway. It looks as though it's an ongoing issue that has yet to be solved. I haven't seen anyone with any solution, yet. There are multiple open threads with no answers in Salesforce help communities and on the dev boards, but no answers. Does anyone have any idea of how to go about beginning this trigger?

At best, what we've come up with is a daily load from Demand Tools to change the Opportunity Owners back to the originals (before changing the Account Owner changed the open Opp Owner by default)

Attribution to: cbro
This content is remixed from stackoverflow or stackexchange. Please visit

My Block Status

My Block Content