+ Start a Discussion

Can I query Partner object from Visualforce page without ViewAllData permission?


I have a Visualforce page that is showing Partners progress towards their quarterly targets

One of the queries is failing for users that do not have the ViewAllData permisson:

FISCAL_QUARTER(p.Opportunity.CloseDate) Qtr, SUM(p.Opportunity.FY_Total__c) Act 
From Partner p 
WHERE p.AccountTo.Name='XXXXXX' 
AND p.IsPrimary=true 
AND p.Opportunity.StageName IN ('04 - Needs Confirmed','05 - Prospect','06 - Meeting Objections','07 - Proposal','08 - Verbal Commitment','09 - Written Commitment','10 - PO in Process','11 - PO Received','12 - PO Received in Finance','13 - Parked') 
AND p.Opportunity.CloseDate=THIS_FISCAL_YEAR 
AND p.Opportunity.Exclude_from_pipeline_reports__c=false 
GROUP BY FISCAL_QUARTER(p.Opportunity.CloseDate) 
ORDER BY FISCAL_QUARTER(p.Opportunity.CloseDate) 

It seems to be the case that the user requires the ViewAllData permission in order to query this data, is that correct?

If that is the case, is there a way round this as otherwise all the sales users will be able to see all the report folders, which is something we want to avoid.

NagaNaga (Salesforce Developers) 
Hi David,

I dont think its a possibe option.

Please check the idea link below


Best Regards
Naga Kiran
Arunkumar RArunkumar R
Hi Dave, 

You can access any records in apex class and show it in visualforce page only if your class NOT enforced with sharing keyword.

You don't need ViewAllData permission for this. If you are referring with sharing keywork in your class, then remove and try it. 



I was doing the query straight from the Visualforce page.

So, an answer might be to do the queries in a controller class and pass the results to the Visualforce page rather than trying to do it all in the Visualforce page.

Thanks for your input,