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
@DEVS@DEVS 

Scheduling reports using Apex

I have a requirement to send weekly reports in email to indivudual memebrs as per their visibility.

I've an idea to write an apex class which I can schedule it using Scheduled Apex.
Inside the class I want to use ReportManager class to run a specific report.

My question here is - How can I run it as a specific user ? 
Suraj Maharjan 3Suraj Maharjan 3
Create a dashboard as a running user and schedule it instead of using apex.
@DEVS@DEVS
Thanks Suraj.
But the question is - How can we do that all users ? Without any manual interuption.
Suraj Maharjan 3Suraj Maharjan 3
On the dashboard page, click on Refresh and then schedule refresh 
refresh

Then schedule it accordingly
User-added image

Make sure on the edit page of dashboard , View Dasboard as: is selected Run as a specified user

User-added image
 
Varun SinghVarun Singh
 Users can schedule reports with criteria based on the report contents. When the platform runs the report, the criteria gets evaluated and if met will result in notifications sent to the user. The usual Email and Chatter options are available, as well Mobile Notifications for Salesforce1 mobile users, pretty cool!

for More detail you can read this article

https://andyinthecloud.com/2015/11/07/supercharging-salesforce-report-subscriptions-with-apex-and-flow/
Bhanu GuptaBhanu Gupta
Hi @DEVS,
You can have only one running user at a time and all the recipients will receive the report with that users's context. So, you need to implement the batch apex for this where you can query all the records related to all the users whom you want to send the report and then can send email to the specific users, after, you can schedule the batch as per your requirement.

https://success.salesforce.com/ideaView?id=08730000000Gnk5AAC