Issues in downloading an invoice by clicking a button

Hi there! I hope someone can help me with my issue :pleading_face:. I made a video about it below.

To make things clear, I am currently using Docupilot as my pdf generator (done via Rest API).
I have set up a workflow which forwards the data to Docupilot and getting the file url and name; and then the next step is updating a variable with the file url from the previous action.

Whenever I click the download button, I can get the right ticket the first time; however, when I jump into the next ticket, it gives me the previous ticket because generating the PDF takes a while.

Can anyone help me with this?

Hi @denisedaley :wave:

Thanks a lot for providing the video, super helpful!

At the beginning of your workflow, before your Generate PDF action, you could try adding a Reset variable value to reset the PDF Download Link variable.

This will ensure that, when the user clicks on the download button, the URL is empty and the workflow generates the new PDF with the new URL before downloading the file.

In addition, you might need to add some sort of await instruction so the browser doesn’t attempt to download the file while the URL is empty.

Let me know if that helps.

If not, I’ll try to put together a tutorial with a similar use case to make things clearer.

1 Like

Hi @Joyce !

Thank you for the fast response! It did worked; however, when I click it, a new tab opens and it’s a blank. It does not downloads the file.
What I did is just create a custom javascript that downloads the file based on the previous workflow and apparently it worked.

But your suggestion is super useful for my other workflow :grin: Thank you so much!

1 Like