Message box after download

Hi,

I would like to have a message box once the csv file has been downloaded.

Table= event.source.parent.getComponent('Table')
csv = system.dataset.toCSV(Table.data)
filePath = system.file.saveFile("LossTime.csv", "csv", "Comma Separated Values")
if filePath:
    system.file.writeFile(filePath, csv)
    
system.gui.messageBox("File Downloaded Successfully", "Loss Time export")

But unfortunately i am getting this message even when i close the file path popup.
How to check whether the file is downloaded so that successful message can be displayed.

Thanks in advance

Try this:

Table= event.source.parent.getComponent('Table')
csv = system.dataset.toCSV(Table.data)
filePath = system.file.saveFile("LossTime.csv", "csv", "Comma Separated Values")
if filePath != -1:
    system.file.writeFile(filePath, csv)
    system.gui.messageBox("File Downloaded Successfully", "Loss Time export")
    

Hi,
I am getting the below error when i close the filepath window,

Hmm ok, that code used to be fine in 7.9, try removing the -1 then:

Table= event.source.parent.getComponent('Table')
csv = system.dataset.toCSV(Table.data)
filePath = system.file.saveFile("LossTime.csv", "csv", "Comma Separated Values")
if filePath:
    system.file.writeFile(filePath, csv)
    system.gui.messageBox("File Downloaded Successfully", "Loss Time export")

Hey thanks. It works