# How to call report from gateway event script \[SOLVED\]

**URL:** <https://forum.inductiveautomation.com/t/how-to-call-report-from-gateway-event-script-solved/26823>\
**Category:** Ignition\
**Tags:** ignition79\
**Created:** [July 23, 2019, 10:33pm UTC](https://forum.inductiveautomation.com/t/how-to-call-report-from-gateway-event-script-solved/26823 "2019-07-23T22:33:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![yehet73190](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yehet73190/32/68157_2.png) [@yehet73190](https://forum.inductiveautomation.com/u/yehet73190)\
**Post date:** [July 23, 2019, 10:33pm UTC](https://forum.inductiveautomation.com/t/how-to-call-report-from-gateway-event-script-solved/26823/1 "2019-07-23T22:33:58Z")

</div>

if i can’t call “system.gui” on a gateway event script, is there an alternative on how i can call the report? what i’m trying to do is when a user clicks on a button from the edge client, the report created on the central server would send the report.

so far i got the other stuff working - the report is able to send when i have a client open on my central server but i can’t always have that open so i thought the script should be added on the gateway event under the tag change script.

this is currently what I need help with

report = event.source.parent.getComponent(‘Report Viewer’)  
attachmentData = [report.getBytesPDF()]  
attachmentNames = [event.source.parent.getComponent(‘Report Viewer’).suggestedFilename + “.pdf”]

how would i convert this so it would work on the gateway event script?

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [July 23, 2019, 10:38pm UTC](https://forum.inductiveautomation.com/t/how-to-call-report-from-gateway-event-script-solved/26823/2 "2019-07-23T22:38:28Z")

</div>

There are two functions you can use: [system.report.executeReport()](https://docs.inductiveautomation.com/display/DOC80/system.report.executeReport) and [system.report.executeAndDistribute()](https://docs.inductiveautomation.com/display/DOC80/system.report.executeAndDistribute)

The first just returns the bytes of the report for you to do what you want with it; the second handles sending the report out for you instead of returning the bytes. That’s usually more convenient if your goal is to email or save the report.

---

<div class="post-metadata">

**Author:** ![yehet73190](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yehet73190/32/68157_2.png) [@yehet73190](https://forum.inductiveautomation.com/u/yehet73190)\
**Post date:** [July 23, 2019, 10:47pm UTC](https://forum.inductiveautomation.com/t/how-to-call-report-from-gateway-event-script-solved/26823/3 "2019-07-23T22:47:21Z")

</div>

awesome it worked! thank you! i used [system.report.executeAndDistribute()](https://docs.inductiveautomation.com/display/DOC80/system.report.executeAndDistribute)

---

<div class="post-metadata">

**Author:** ![yehet73190](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yehet73190/32/68157_2.png) [@yehet73190](https://forum.inductiveautomation.com/u/yehet73190)\
**Post date:** [July 23, 2019, 11:15pm UTC](https://forum.inductiveautomation.com/t/how-to-call-report-from-gateway-event-script-solved/26823/4 "2019-07-23T23:15:37Z")

</div>

quick question tho, how come its sending me two emails instead of 1?

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [July 29, 2019, 2:04pm UTC](https://forum.inductiveautomation.com/t/how-to-call-report-from-gateway-event-script-solved/26823/5 "2019-07-29T14:04:04Z")

</div>

You probably have something misconfigured – when I test it, it only sends me one.
