7

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.

Suggestions?

4 Answers 4

2

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

Have you looked at enabling Team Selling?

http://login.salesforce.com/help/doc/en/customize_teamselling.htm

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.

1
1

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)

1

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){
            actIds.add(a.id);
        }
        list<Opportunity> opps = [Select id, accountid, ownerid, owner.name from Opportunity where accountid in :actids];
        beforeUpdateMap=new map<id,id>();
        for(Opportunity o : opps){
            system.debug('***Opp owner on Account beforeUpdate:'+o.owner.name);
            beforeUpdateMap.put(o.accountid,o.ownerid);
        }
    }

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

        set<id> actIds = new set<id>();
        for(Account a : newAccounts){
            actIds.add(a.id);
        }
        list<Opportunity> updateOpps = new list<Opportunity>();
        list<Opportunity> opps = [Select id, isClosed, accountid, ownerid, owner.name 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) ){
                o.ownerid=beforeUpdateMap.get(o.accountid);
                updateOpps.add(o);
            }
        }
        //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;
    }



}
-1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .