# Automatic save report doesn't work

**URL:** <https://forum.inductiveautomation.com/t/automatic-save-report-doesnt-work/21859>\
**Category:** Ignition\
**Tags:** ignition79, scripting\
**Created:** [January 14, 2019, 12:37pm UTC](https://forum.inductiveautomation.com/t/automatic-save-report-doesnt-work/21859 "2019-01-14T12:37:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jens1011](https://avatars.discourse-cdn.com/v4/letter/j/e274bd/32.png) [@jens1011](https://forum.inductiveautomation.com/u/jens1011)\
**Post date:** [January 14, 2019, 12:37pm UTC](https://forum.inductiveautomation.com/t/automatic-save-report-doesnt-work/21859/1 "2019-01-14T12:37:14Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![JGJohnson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jgjohnson/32/29582_2.png) [@JGJohnson](https://forum.inductiveautomation.com/u/JGJohnson)\
**Post date:** [January 14, 2019, 1:39pm UTC](https://forum.inductiveautomation.com/t/automatic-save-report-doesnt-work/21859/2 "2019-01-14T13:39:27Z")

</div>

It’s because your script is opening the popup. Rework your script to remove the call to system.file.saveFile().

---

<div class="post-metadata">

**Author:** ![jens1011](https://avatars.discourse-cdn.com/v4/letter/j/e274bd/32.png) [@jens1011](https://forum.inductiveautomation.com/u/jens1011)\
**Post date:** [January 14, 2019, 1:49pm UTC](https://forum.inductiveautomation.com/t/automatic-save-report-doesnt-work/21859/3 "2019-01-14T13:49:26Z")

</div>

how do i that? i tried but it nothing helped.

---

<div class="post-metadata">

**Author:** ![JGJohnson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jgjohnson/32/29582_2.png) [@JGJohnson](https://forum.inductiveautomation.com/u/JGJohnson)\
**Post date:** [January 14, 2019, 2:04pm UTC](https://forum.inductiveautomation.com/t/automatic-save-report-doesnt-work/21859/4 "2019-01-14T14:04:40Z")

</div>

I also fixed the mistake in your writefile() call. You had “bytes” instead of “reportBytes” in there.

```auto
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 )

```

---

<div class="post-metadata">

**Author:** ![Sanderd17](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sanderd17/32/8735_2.png) [@Sanderd17](https://forum.inductiveautomation.com/u/Sanderd17)\
**Post date:** [January 14, 2019, 2:05pm UTC](https://forum.inductiveautomation.com/t/automatic-save-report-doesnt-work/21859/5 "2019-01-14T14:05:34Z")

</div>

Please read the documentation:

[`system.file.saveFile`](https://docs.inductiveautomation.com/display/DOC79/system.file.saveFile) creates the “save file” dialog. While [`system.file.writeFile`](https://docs.inductiveautomation.com/display/DOC79/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.
