My org is running some apex code that pulls objects and passes them to a mobile app. The apex code in question is designed to be run as the sales rep that is logged in via the app. For some reason when I query for the pricebook and pricebookentry objects it seems the apex flips into god-mode and pulls all of the PBs and PBEs, even though there is only one pricebook shared with a certain user.
Are there specific settings that will make the PBs and PBEs adhere to sharing rules when querying via Apex?
APEX:
String query = constructQuery(ce, lastModifiedDate, offsetId, True);
Query returned from constructQuery(): SELECT Id, CurrencyIsoCode, LastModifiedDate FROM Pricebook2 WHERE (IsActive=true) ORDER BY Id DESC LIMIT 5000
List<SObject> objs = Database.query(query);
if (objs != null && objs.size() > 0) {
response.records.addAll(objs);
}
This is a known issue apparently. Follow below link (last warning box at the bottom of the page): http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_security_sharing_rules.htm?SearchType=Stem