You need to sign in to do that
Don't have an account?
Without sharing keyword not behaving as I thought
I am a bit of a noob so my question may be simple for someone to answer. I do give kudos and follow up on threads for those who care about that.
Basically my issue is this:
I have a VF page, custom tab and APEX class that is meant to allow a user to go to the tab and see a related list of cases for their contact record. Their contact record is under an account tha tthey are not supposed to have access to so I thought having the without sharing keyword in the class would work but I am getting an error when I go to that tab as that logged in user. Since the class operates at the system level why am I getting error messages based on the sharing settings? Any thoughts would be appreciated. (Oh, the code works because when I go to that tab as the admin it works as intended)
Below is my VF page and Class.
<apex:page standardController="Case" extensions="CC_getContact"> <apex:tabpanel > <apex:tab label="Cases"> <apex:relatedList list="Cases" subject="{!theContact}"/> <style type="text/css">.actionColumn {display:none; visibility:hidden}</style> </apex:tab> </apex:tabpanel> </apex:page>
//This Class is used to get the contact record of the current logged in user for use in a visualforce page. public without sharing class CC_getContact { public Contact theContact { get; set; } // You can use theContact on your page. public CC_getContact(ApexPages.StandardController controller) { Contact[] c = [SELECT Id FROM Contact WHERE FirstName = :UserInfo.getFirstName() AND LastName = :UserInfo.getLastName() and Email = :UserInfo.getUserEmail()]; // Make sure you select all the fields you need. if(!c.isEmpty()) { theContact = c[0]; } } }
The target profile has access to the tab and VF page. Is there some permission issues posibly?
Submitted a case to Salesforce Premiere support and got the problem resolved.
There is a system permission on the user profile I needed to have selected. The permission is "Author Apex"
All Answers
May be thats y you are getting error ?
system.debug('\n ### contacts ' + c.size() + ' => ' + c);
If the problem still exists then I recommend you to post the error message?
2. check or add the profile to security of vf to have the profile access the page
3. same thing on number 2 but this time check it for the security of the class used in vf
Submitted a case to Salesforce Premiere support and got the problem resolved.
There is a system permission on the user profile I needed to have selected. The permission is "Author Apex"