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
xiaoluluxiaolulu 

How do I figure out sharing rules from the API

We are working on a forecasting app and we need to figure out whether the logged in user has the rights to view someone elses forecast and if yes then whos (which role/user).My questions are:
 
1) Is there a way to figure this out through the API. If yes how and which tables give me that info.
2) Also which tables give the security info. e.g - whether I am allowed to see someone elses data (e.g Opportunities for ppl above or below me in the hierarchy) and if yes what security permissions do i have to look at in teh API.
 
It would be great to get some help ont he above
 
Thanks
 
advlgxpmadvlgxpm
Don't know the specifics you are looking for, but you can start with the AccountShare and OpportunityShare tables from any tool you use to read the API. Those table's UserOrGroupId fields will link to specific users in the user table and then where the id represents a group, look at the Group and GroupMember tables. The QueuesObject table may also come into play with the Group table, if you use them.
RickyGRickyG
xiaolulu -

You probably want to walk the role hierarchy, which I believe you can do with the ParentRoleId in the UserRole object.  Parent roles always have all the sharing privileges of their child role.  User groups can also affect sharing, as pointed out above.

Hope this helps.
rfanrfan

Is there a recommended way of figuring out the sharing rules from the API in the Summer 2010 version of Salesforce?  This is an old message board post, so I'm thinking there may be a new and improved way for this in the new Salesforce release.

 

In other words, I need to figure out which Salesforce Accounts and Contacts a Salesforce User has access to via the API.  Is this possible?

VarunCVarunC

I believe "with sharing" clause appended to your Class automatically applies sharing rules for users who execute the code.

 

http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_classes_keywords_sharing.htm