How to call report from gateway event script [SOLVED]

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?

There are two functions you can use: system.report.executeReport() and 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.

awesome it worked! thank you! i used system.report.executeAndDistribute()

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

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