You need to sign in to do that
Don't have an account?

Opportunity Share is deleted when owner is changed
Hi ,
I am inserting records into the opportunityShare object programtically thru a trigger, while inserting the record I am setting the userOrGroupID field in the oppotunityShare to a public group. When I change the owner of the opportunity, all these sharing records get deleted. While if I change any other field on the opportunity, the records in the opportunityShare object are intact.
Could anyone please let me know as to why this behaviour is happening?? And how can we avoid this?
Regards
Sam
This is standard behavior. Changing the owner of an opportunity automatically removes all shares from it. See https://help.salesforce.com/htviewhelpdoc?id=account_owner.htm&siteLang=en_US ... Basically, sharing reverts back to the default values for the organization, except for those shares that result from an opportunity or account team.
All Answers
This is standard behavior. Changing the owner of an opportunity automatically removes all shares from it. See https://help.salesforce.com/htviewhelpdoc?id=account_owner.htm&siteLang=en_US ... Basically, sharing reverts back to the default values for the organization, except for those shares that result from an opportunity or account team.
Thanks for the reply. Is there anyway we can stop this from happeing apart from adding all the existing share records tru trigger when the owner of the opportunity is changed(which I am doing right now.) ??
Thanks
Sam
Nope. This is standard functionality. You can't prevent standard functionality, you have to work around it.
See: https://help.salesforce.com/articleView?id=security_apex_sharing_reasons.htm&type=5 for more information.
All JungLeee needs to do is to set up a specific Apex Sharing Reason for the insert, and the share will not be removed when the record ownership changes.
Unfortunately that isn't an option (I wish it were!).
Apex managed sharing (including sharing reasons) are not available for standard objects like opportunity.