+ Start a Discussion
Ventzi IankoulovVentzi Iankoulov 

Custom Object sharing after Master-Detail to Lookup relationship change

Hi guys,

Please can you help me understand platform behavior in the following situation.
I’m testing a change of relationship between standard Case object and a custom object, let’s call it simply “customObject”.
In the course of the testing (on a sandbox) I have notice that when I change the relationship from the current Lookup to  Master-Detail  previously existing customObject__Share disappears. I think this is Ok and expected, but if I revert the relationship from Master-Detail back to Lookup no new customObject__Share get created. 
I have observed this on two different instances.

Is this normal behavior?
I would have expected that when I convert a relationship from Master-Detail to Lookup a new customObject__Share will be automatically created!?

If this is normal, I'm wondering how the platform is handling the sharing of a custom object, which originally was on a Detail side of a Master-Detail relationship, but at some point of time the relationship was change to Lookup?


Thank you very much in advance!
Ventzi
Best Answer chosen by Ventzi Iankoulov
ShirishaShirisha (Salesforce Developers) 
Hi Ventzi,

Greetings!

Please be informed that the customObject__share Object will be created by the system,if the OWD of the CustomObject is set to "Public Read Only" or Private.

If it is set to Public Read/Write then the customObject__Share Object will not be created as it will be available for the all the users.

So this behavior doesn't depends on the type of the relationship but on the access level of the Object.If you would like to create the customObject__c then you would need to the access level to "Public Read Only" or Private..

Reference:https://salessforcehacks.blogspot.com/2020/01/apex-managed-sharing-with-real-time.html

Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri

All Answers

ShirishaShirisha (Salesforce Developers) 
Hi Ventzi,

Greetings!

Please be informed that the customObject__share Object will be created by the system,if the OWD of the CustomObject is set to "Public Read Only" or Private.

If it is set to Public Read/Write then the customObject__Share Object will not be created as it will be available for the all the users.

So this behavior doesn't depends on the type of the relationship but on the access level of the Object.If you would like to create the customObject__c then you would need to the access level to "Public Read Only" or Private..

Reference:https://salessforcehacks.blogspot.com/2020/01/apex-managed-sharing-with-real-time.html

Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri
This was selected as the best answer
Ventzi IankoulovVentzi Iankoulov
Hi Shirisha,
thank you very much for the explanation and the provided reference!
It makes sense and indeed, as soon as I set the object’s OWD to Private the sharing object was created.
Obviously I had wrong understanding that the CustomObject__Share Object
is created at the time of the object creation and not dependent on the OWD.

Once again thank you very much!
Ventzi