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
amar joshiamar joshi 

Regarding sharing property on object level

Hi all,


Is there any method so i can get the object' s sharing property i.e. "Private" or 'Public Read only' on sobject level, so i can do below process 


if(Mycustomobj__C.IsSharing() == 'Private')



//so  i can do global describe i can get Mycustomobj__Share and i can do my  logic.this is because more logical check




You can access the sharing property by querying "Share" objects. Observe the saleforce.schema carefully, you will find objects like AccountShare, ContactShare, LeadShare, CaseShare, ForecastShare and some objects with the suffix "_Share" (for custom objects). In these objects you will find picklist fields like AccountAccessLevel, ContactAccessLevel, OpportunityAccessLevel and AccessLevel(for custom objects). These picklist contains the value Read Only, Read/Write and Owner. You can query these objects and find the sharing property. Find below a sample query :


Opportunity opp = [Select,o.OpportunityAccessLevel From OpportunityShare o where o.OpportunityAccessLevel ='Read Only'];


Did this answer your question? if so, please mark it solved.