+ Start a Discussion
kiran punurukiran punuru 

Can we stop opportunity owner change

Hi ,

Can we stop the opportunity owner change for open opportunities when an account owner is changed,please advice on this ..

Regards,
Kiran
SRKSRK

When we change the account owner there will be a option come says
Transfer open opportunities not owned by the existing account owner

so you want a vlaidation that if user select this, slesforce won't allow to chagne the owner of oppotunity 


because if you just want to stop user from changeing oppotunity owner i belive we can achive the same useing vlaidation rule or trigger
m i correctm ?

kiran punurukiran punuru
Hi SRK,
Thanks for your reply,
There is an option in account owner transfer page that is :Transfer open opportunities not owned by the existing account owner.
How can we write a validation rule at that transfer page ,can u tell in detail please.

Regards,
Kiran.
SRKSRK
You can try triggers to achive the same

create a trigger on account which run on owner update and set a static varible, 
So if the Transfer open opportunities not owned by the existing account owner check box is checked salesforce will try to update the oppotunities also
in the 2nd phase write a trigger on opputnity and check that if owner is changing and static varible is ture, which menas this trigger is executed from account trigger

Hope that make sence and static varible mentain it value throw out the execution cycle on syscronus code 

Thanks
 
Deeprao18Deeprao18
We created the followiing workaround.  The reason it works is related standard object records are not updated if you change the native account Owner field using the Process Builder or DataLoader.

1) Create a custom loopkup field  called "Account Owner" with a lookup to the User object
2) Create a Process Builder to update account OwnerID field with the user ID from the custom Account Owner field.  Trigger the process builder using ISCHANGED criteria on the custom Account Owner field.
3) Optional - remove the native account Owner field from the Account page layout(s).

We have implemented this and was successful. Please mark this as best answer if it worked for you all
Deeprao18Deeprao18
Hi All,

There is catch here, whenever the Account Owner is changed from the UI by clicking change, it will automatically update all the open opportunities to the new owner.

But when the same Account owner is updated from Code i.e. Anonymous window or any 3rd party integration, we need to write a trigger to achieve this functionality, I have already written the trigger for the same and anyone needs help with it I am always here

Thanks.