SOQL query to show a result based on dashboard running user - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Ankit RatawaAnkit Ratawa 

SOQL query to show a result based on dashboard running user

Hi All,

I created a report on a custom object by using APEX and VF page and used it in a dynamic dashboard. my SOQL query in APEX I used was

Select a,b,c from X WHERE Account__r.OwnerId =:UserInfo.getUserId()

but by doing this it only shows accounts that user owned and managers can't see the result. if I remove this then user can see everything even though they don't own this account in the VF page (OWD is private). Is there a way I can filter the result on SOQL based on the dashboard running user in the dynamic dashboard instead of the log-in user. 

Thanks,
Ankit
Keiji OtsuboKeiji Otsubo
Hi Ankit,

Please check this article.
https://developer.salesforce.com/forums/?id=906F000000097AwIAI