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
sunfishettesunfishette 

Sharing Rules

Quick question:

 

I have a SOQL call in my apex class that returns all the opportunity records from a logged in user and displays them on a VF page.  I just figured out that there are some users that have Sharing rules (manual sharing) that connects two different accounts and the records from both accounts are not displaying (despite 'public with sharing' being used in the definition of my class) .

 

IE...

Bob Smith logs in

Bob is with Company ABC

Bob also has access to Opportunity records from Company MNO and XYZ.

In Bobs Opportunity tab, he can see all the records from the three different companies, but he can only see the records from his ABC company displayed on the Visual force page. 

 

Is there something simple that I am missing?  Is there a typical line of apex code that connects the SOQL call to all shared accounts?  I had originally  thought that "WITH SHARING" automatically caused the users login rules to apply to the apex class and all its methods.

 

Thoughts?

Thanks!

sfdcfoxsfdcfox

One of two scenarios must be true:

 

1) you've encountered a bug with sharing, and should submit a case to Technical Support, or

2) your SOQL query, or the logic leading up to that query, is somehow incorrect.

 

You'd be incredibly surprised how easy it is to come across the second scenario, especially when it happens to be a quirk of the system and not actually anything you've done wrong. Try checking your filters, and if they are dynamically bound, the inputs to those filters. You might also post your query here and see if we can spot something.

sunfishettesunfishette

sfdcfox --

 

It was indeed in my SOQL query.  I needed to pull from AccountShare and compare to UserOrGroupId instead of the id from the user (userinfo.getuserid)

 

 

:O