In salesforce we cannot have scheduled email export. Below solution could help to get the scheduled export of the reports as CSV. For this I have used “Execute a Custom Action” feature when we subscribe to email notification. Salesforce has provided feature where Apex code can be executed if the condition specified while subscribing report is met.
You can use code from : https://gist.github.com/kiran-machhewar/ff0f2ca55b89b793ad88973f7701feb0
In order to get the scheduled export of Report data, report has to be subscribed and while subscribing report select “Execute a Custom Action” and select EmailReportExport class. As per the schedule provided as soon as the conditions are met then execute method from EmailReportExport will get invoked. In the execute method csv data is created by Analytics api in Apex.
Subscribe the report in below way:
When the condition for the report subscription is met at scheduled time you will get the email notification as in below snapshot:
- No email limits are consumed since email would be sent to the user who has subscribed the email.
- Same EmailReportExport handler can be used with different reports.
Only 2000 records will be available as a csv export.
Happy learning 🙂