# Report Editing with Scripting

**URL:** <https://forum.inductiveautomation.com/t/report-editing-with-scripting/41131>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [December 2, 2020, 3:04pm UTC](https://forum.inductiveautomation.com/t/report-editing-with-scripting/41131 "2020-12-02T15:04:56Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaushik.shah](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@kaushik.shah](https://forum.inductiveautomation.com/u/kaushik.shah)\
**Post date:** [December 2, 2020, 3:04pm UTC](https://forum.inductiveautomation.com/t/report-editing-with-scripting/41131/1 "2020-12-02T15:04:56Z")

</div>

Hello There,

I am trying to print multiple copies of the report with one parameter change with below script -

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/4/c48f9760c560b82b1994757621c6a23b078528d6.png)

Here the maxBobineNo = 5 let say,

but when the pdf is printed, all of them has the same value of parameter bobineNo.

any idea ?

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [December 2, 2020, 3:07pm UTC](https://forum.inductiveautomation.com/t/report-editing-with-scripting/41131/2 "2020-12-02T15:07:08Z")

</div>

> event.source.parent.BobineNo += 1  
> name = 'Test Report ' + str(event.source.parent.BobineNo)

---

<div class="post-metadata">

**Author:** ![bpreston](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bpreston](https://forum.inductiveautomation.com/u/bpreston)\
**Post date:** [December 2, 2020, 3:21pm UTC](https://forum.inductiveautomation.com/t/report-editing-with-scripting/41131/3 "2020-12-02T15:21:03Z")

</div>

I’d be curious where your running this script. I could be wrong but I would expect when you change the parameter that your report is going to have to run again. Your script though is going to fly through it and I wouldn’t expect it to wait for the report to finish updating. You may need to use [system.report.executeAndDistribute()](https://docs.inductiveautomation.com/display/DOC81/system.report.executeAndDistribute) instead.

---

<div class="post-metadata">

**Author:** ![kaushik.shah](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@kaushik.shah](https://forum.inductiveautomation.com/u/kaushik.shah)\
**Post date:** [December 2, 2020, 4:03pm UTC](https://forum.inductiveautomation.com/t/report-editing-with-scripting/41131/4 "2020-12-02T16:03:09Z")

</div>

Same result

---

<div class="post-metadata">

**Author:** ![kaushik.shah](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@kaushik.shah](https://forum.inductiveautomation.com/u/kaushik.shah)\
**Post date:** [December 2, 2020, 4:05pm UTC](https://forum.inductiveautomation.com/t/report-editing-with-scripting/41131/5 "2020-12-02T16:05:36Z")

</div>

Yes, but the issue is, system.report.executeAndDistribute runs on Gateway but the printer where the job needs to be printed would not be accessible from Gateway.  
Perhaps just execute after every iterate would work (which don’t know if possible)

---

<div class="post-metadata">

**Author:** ![bpreston](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bpreston](https://forum.inductiveautomation.com/u/bpreston)\
**Post date:** [December 2, 2020, 4:23pm UTC](https://forum.inductiveautomation.com/t/report-editing-with-scripting/41131/6 "2020-12-02T16:23:22Z")

</div>

How about using [system.report.executeReport()](https://docs.inductiveautomation.com/display/DOC81/system.report.executeReport). It will return the bytes of the report, then you should be able to save it from there. I’d expect this to work with your system.file.writeFile() function.

---

<div class="post-metadata">

**Author:** ![kaushik.shah](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@kaushik.shah](https://forum.inductiveautomation.com/u/kaushik.shah)\
**Post date:** [December 2, 2020, 4:23pm UTC](https://forum.inductiveautomation.com/t/report-editing-with-scripting/41131/7 "2020-12-02T16:23:54Z")

</div>

Yes, did that -

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/d/2dd58573cb590ccd774492cbf6a35bbaa4ddb4a2.png)

Worked fine.

Thanks so much @bpreston, @MMaynard

---

<div class="post-metadata">

**Author:** ![bpreston](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bpreston](https://forum.inductiveautomation.com/u/bpreston)\
**Post date:** [December 2, 2020, 4:34pm UTC](https://forum.inductiveautomation.com/t/report-editing-with-scripting/41131/8 "2020-12-02T16:34:41Z")

</div>

Just for in the future, one other idea that may of worked for you, the way you had it originally is utilizing the reportLoading function. If the report is printed each time you could also utilize this in a loop to allow you to use the print function to automatically print the report as it is run. An example of this is at the bottom of the [report viewer page](https://docs.inductiveautomation.com/display/DOC81/Vision+-+Report+Viewer) in the manual. Its labeled as utilizing reportLoading.

---

<div class="post-metadata">

**Author:** ![kaushik.shah](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@kaushik.shah](https://forum.inductiveautomation.com/u/kaushik.shah)\
**Post date:** [December 2, 2020, 6:51pm UTC](https://forum.inductiveautomation.com/t/report-editing-with-scripting/41131/9 "2020-12-02T18:51:58Z")

</div>

I actually would have to use this because, with the way I did it before, it gives me the bytesArray for the file type I select which is okay for storing the data but with this, I can easily print to a label printer.

Thanks so much
