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

How to create a __share object for Custom Object
Hi All,
How can I create a __share for a custom object.
For Ex: I have created a custom object named MyObject and how can I create a share object for it named MyObject__Share.
Note: I have the permission Manage Users as described in the docs.
Any help is appreciated.
Thanks
Hello Bagu,
Please take look at
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_bulk_sharing_creating_with_apex.htm
This is matching with your requirement. Please mark as resolved if it solves your problem.
Hi
I wanted to know when and how the __share object is created for any custom object . In the link provided I see that a __share object is already created and we are instantiating a new instance of that object.
It would be great if somebody could let me know whan and how is the __share object created. I am not able to see the __share object in the Schema.
Thanks
Hi,
You cann't create "__share" object by yourself. System create it for you. If shareing setting of an object is "Public Read/Write" system will not create "__share" object, as there is no scope of sharing, all record is open to everybody in org. However, if sharing setting of object is either "Public Read Only" or "Private", system itself create a "__share" object for you.
Please let me know if you have any question about above.
Happy to help you!
__Share objects are created automatically based on the OWD settings in the org.
Regards,
Satish Kumar
Hi,
Create a custom object and Goto
Setup->Security Controls->Sharing Settings,
and select your object and make Object Private .
By Default if OWD of the object is not set to most permissive access level(Public Read/Write) ,Then there will be automatically share object created for the existing object .
For Example if OWD for 'Account' is not set to Public Read/Write then 'AccountShare' object will be existing in the back-ground .
Please check below post which can help you understand with simple real time example .
Apex Managed Sharing with use case explained (https://salessforcehacks.blogspot.com/2020/01/apex-managed-sharing-with-real-time.html)