3

My Org uses Salesforce Lightning.

I am trying to develop a Custom Link for an SF object that redirects to a report, modifies a filter through the URL and automatically downloads the .CSV file of that report in the browser.

The URL i am trying to redirect to looks like: https://[org.instance].lightning.force.com/lightning/r/Report/[reportId]/view?fv0=1000

This successfully opens the report and modifies the filter. At this point, to export the file I would have to click on export, choose the 'Details Only' option and click 'Export' which would download the file I want.

Is there a way to accomplish this behaviour through the Custom link (URL) such that the user clicks on the link and the file gets downloaded automatically?

I have researched solutions and found posts such as Custom link to download/export report in single click, however this approach did not work in my case. the URL params given are not working.

1 Answer 1

3

You can download a report using a link in Lightning but the catch is you will not be able to set the Filters dynamically from the URL.

If you are just looking for something which will simply download the Report you can use the below URL -

'/servlet/PrintableViewDownloadServlet?isdtp=p1&reportId={your_report_Id}'

replace your_report_Id with the report Id. Then append the above url to you base url.

4
  • I had tried that, too bad you can't add a filter. Can you explain what the servlet is and is there a resource where we can get additional info on these types of url's and the actions they provide? (I can always create a new question)
    – Z33dawg
    Feb 16, 2019 at 17:12
  • @Z33dawg there is no official documentation on this as this is kind of hack in salesforce, they don't provide any documents on this. As far as Servlet is concerned,almost all kind of downloadable files resides within Servlet in Salesforce. Feb 18, 2019 at 6:55
  • Hi this is an awesome find, do you know if we can use this to download the report in full details view please ?
    – Etienne
    May 1, 2019 at 0:35
  • @AvinashKumar Is there any documentation for this? Specifically, how might I be able to export as CSV?
    – Diego
    May 15, 2019 at 4:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .