function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

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.



Niket SFNiket SF

Hello Bagu,


  Please take look at


 This is matching with your requirement. Please mark as resolved if it solves your problem.






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.






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!

Yes as digamberlucky explained,
__Share objects are created automatically based on the OWD settings in the org.

Satish Kumar
Satyendra RawatSatyendra Rawat



Create a custom object and Goto

Setup->Security Controls->Sharing Settings,

and select your object and make Object Private .

Angela CapazAngela Capaz
Thanks everyone for these answers :) Very helpful.
Hi bugu,
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 (
Faizan Shaikh 6Faizan Shaikh 6
Is it possible to edit the Row Cause picklist field for MyCustom__Share object?