Cant Get Syntax on report viewer How to trigger script from a plc tag going high? (trigger)

I have googled this to death but the responses are not enough to google the answer.

I have a report made up, and a script that runs it on a push button to email out the report as a PDF. Google says that Tag events run globally, and that some how I am supposed to use A client tag to trigger the report(I also need a client open and running and can not trigger reports off of a plc tag in the current version of ignition). I have the same problem with a client tag that I do with the push button. How do I make the client tag trigger based off of a PLC bit/tag?

Every google answer says “use” “X or Y” but i google X or Y and can not figure out how to configure it.

After Reading and watching video 5
https://inductiveuniversity.com/video/tag-scripts?r=/course/scripting

I am trying to use a Client Tag Event Script to trigger my script but I have an error with syntax.

#Get Report Data
fileName = "AVC_OEE_Report.pdf"
fileData = event.source.parent.getComponent('Report Viewer').getBytesPDF()


# Send Email Details
smtp = "SMTP.johndoe.com"
sender = "SPD.AVCLine@johndoe.com"
subject = "AVC OEE REPORT"
body = "Attached is the PDF Report"

#edited email since it is a public forumn
recipients = ["JohnDoe@test.com"]



system.net.sendEmail(smtp, sender, subject, body, 0, recipients, [fileName], [fileData])

I get a Sytax error on line 3 for
event.source.parent.getComponent(‘Report Viewer’).getBytesPDF()

error says
File “TagChangeScript:AVC/TestEmailScriptOnTagHigh”, line 3, in
AttributeError: ‘com.inductiveautomation.ignition.client.sqltags.im’ object has no attribute ‘parent’

Is there not a syntax to pull the pdf straight from the report? I have a report called AVC_OEE in the Reports section of my project browser.

What version of Ignition?

Also, please edit your post to include formatting controls for your code: Three back-quotes above the code, and again below the code. These: ```

You probably also want to obscure the email addresses… this is a public forum.

1 Like
gnition Platform 7.9.4 (b2017082911)  
Reporting Module 4.9.4 (b2017082911) Activated
Alarm Notification Module 4.9.4 (b2017082918) Activated
Barcode Scanner Module 1.9.4 (b1709061009) Activated
SFC Module 3.9.4 (b2017082918) Trial
Enterprise Administration Module 2.9.4 (b2017082911) Trial
DNP3 Driver Module 2.9.4 (b2017082911) Trial
OPC-UA Module 4.9.4 (b2017082911) Activated
Vision Module 9.9.4 (b2017082918) Activated
SQL Bridge Module 8.9.4 (b2017082911) Activated
OpcCom Module 4.9.4 (b2017082918) Trial
Symbol Factory Module 5.9.4 (b2017082918) Activated
Mobile Module 4.9.4 (b2017082911) Activated

So, google is wrong for your version of Ignition. You do not need a client open. You should not be using either client tags or client event scripts. You should be using a gateway tag change script, monitoring the PLC tag you are interested in, and that script should use the system.report.executeAndDistribute() function.

1 Like

# Executes and distributes the report to an email address.

system.report.executeAndDistribute(path = "My Report Path" , project = "My Project" , action = "email" ,

actionSettings = { "to" :[ "plantmanager@myplant.com" ], "smtpServerName" : "myplantMailServer" , "from" : "reporting@myplant.com" , "subject" : "Production Report" })

I will still have an issue with the “My Report Path” syntax

What do you mean? This is just the name of your report as shown in the designer tree (with folder names if any).

1 Like

Thank you so much for your quick replies. I will begin testing.

Note that the actionSettings parameter changed in v7.9.8. If it doesn’t work the way you want, you’ll need to use system.report.executeReport() instead, construct the email+attachment manually, using system.net.sendEmail().

1 Like