Save Button not working

I have the following code for a button that allows the user to save the report in the report viewer as a pdf

[code]from java.util import Date

table = event.source.parent.getComponent(‘Report Viewer’)

now = Date()

fileDate = system.db.dateFormat(now, “MM d, yyyy”)

filename = fileDate + “_” + “Report” + “.pdf”

filePath = system.file.saveFile(filename, ‘pdf’, ‘report’)[/code]

The popup box comes up as if you were saving a document, but it does not actually save the document to the computer. What am I missing? It’s not throwing any errors, it’s just simply not saving the document to the computer.

system.file.saveFile does not save files. It only returns the path the user selected and provides a Save File dialog.

The documentation shows one way to actually write the file to disk (see link above).

Edit: I think you will only need to use system.file.writeFile

Thanks JGJohnson!

I was just about to post the same thing! When I had posted this post, inductive university was down, but now it’s up and the video about the report viewer was exactly what I needed and your link is even better and more direct! Thanks so much!

You’re welcome. :thumb_right: