I want to save a report automatically. now I have written this code, but I still get a pop up to select a path. does anyone know what I’m doing wrong?
report = event.source.parent.getComponent(‘Parameter viewer’)
d = system.date.format(system.date.now(),“MM-dd-yyyy hh-mm-ss”)
reportBytes = report.getBytesPDF()
filepath = (“S:\Factory\Reporting\Ignition”)
filename = system.file.saveFile (str(‘para-’+d))
if filename != None:
system.file.writeFile(filename, bytes)
It’s because your script is opening the popup. Rework your script to remove the call to system.file.saveFile().
2 Likes
how do i that? i tried but it nothing helped.
I also fixed the mistake in your writefile() call. You had “bytes” instead of “reportBytes” in there.
report = event.source.parent.getComponent(‘Parameter viewer’)
d = system.date.format(system.date.now(),“MM-dd-yyyy hh-mm-ss”)
reportBytes = report.getBytesPDF()
filepath = “S:\Factory\Reporting\Ignition\para-%s” % d
system.file.writeFile(filepath , reportBytes )
1 Like
Please read the documentation:
system.file.saveFile
creates the “save file” dialog. While system.file.writeFile
actually writes the file to the disk.
If you already know the exact path you want to save to, there’s no need for a popup, and thus no need to call the saveFile
.
PS. Please wrap code blocks in triple backticks (```), that makes it a lot easier to read.
3 Likes