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

**URL:** <https://forum.inductiveautomation.com/t/cant-get-syntax-on-report-viewer-how-to-trigger-script-from-a-plc-tag-going-high-trigger/22545>\
**Category:** Ignition\
**Created:** [February 13, 2019, 4:08pm UTC](https://forum.inductiveautomation.com/t/cant-get-syntax-on-report-viewer-how-to-trigger-script-from-a-plc-tag-going-high-trigger/22545 "2019-02-13T16:08:02Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![JeremyAdair87](https://avatars.discourse-cdn.com/v4/letter/j/c89c15/32.png) [@JeremyAdair87](https://forum.inductiveautomation.com/u/JeremyAdair87)\
**Post date:** [February 13, 2019, 4:08pm UTC](https://forum.inductiveautomation.com/t/cant-get-syntax-on-report-viewer-how-to-trigger-script-from-a-plc-tag-going-high-trigger/22545/1 "2019-02-13T16:08:02Z")

</div>

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](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.

```auto
#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.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 13, 2019, 4:13pm UTC](https://forum.inductiveautomation.com/t/cant-get-syntax-on-report-viewer-how-to-trigger-script-from-a-plc-tag-going-high-trigger/22545/2 "2019-02-13T16:13:38Z")

</div>

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: ```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 13, 2019, 4:15pm UTC](https://forum.inductiveautomation.com/t/cant-get-syntax-on-report-viewer-how-to-trigger-script-from-a-plc-tag-going-high-trigger/22545/3 "2019-02-13T16:15:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JeremyAdair87](https://avatars.discourse-cdn.com/v4/letter/j/c89c15/32.png) [@JeremyAdair87](https://forum.inductiveautomation.com/u/JeremyAdair87)\
**Post date:** [February 13, 2019, 4:16pm UTC](https://forum.inductiveautomation.com/t/cant-get-syntax-on-report-viewer-how-to-trigger-script-from-a-plc-tag-going-high-trigger/22545/4 "2019-02-13T16:16:28Z")

</div>

| **gnition Platform** | `7.9.4 (b2017082911)` | &nbsp; |
| --- | --- | --- |
| **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 |

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 13, 2019, 4:20pm UTC](https://forum.inductiveautomation.com/t/cant-get-syntax-on-report-viewer-how-to-trigger-script-from-a-plc-tag-going-high-trigger/22545/5 "2019-02-13T16:20:06Z")

</div>

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()](https://docs.inductiveautomation.com/display/DOC79/system.report.executeAndDistribute) function.

---

<div class="post-metadata">

**Author:** ![JeremyAdair87](https://avatars.discourse-cdn.com/v4/letter/j/c89c15/32.png) [@JeremyAdair87](https://forum.inductiveautomation.com/u/JeremyAdair87)\
**Post date:** [February 13, 2019, 4:22pm UTC](https://forum.inductiveautomation.com/t/cant-get-syntax-on-report-viewer-how-to-trigger-script-from-a-plc-tag-going-high-trigger/22545/6 "2019-02-13T16:22:19Z")

</div>

`# 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

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 13, 2019, 4:24pm UTC](https://forum.inductiveautomation.com/t/cant-get-syntax-on-report-viewer-how-to-trigger-script-from-a-plc-tag-going-high-trigger/22545/7 "2019-02-13T16:24:55Z")

</div>

> [@JeremyAdair87](#):
>
> 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).

---

<div class="post-metadata">

**Author:** ![JeremyAdair87](https://avatars.discourse-cdn.com/v4/letter/j/c89c15/32.png) [@JeremyAdair87](https://forum.inductiveautomation.com/u/JeremyAdair87)\
**Post date:** [February 13, 2019, 4:25pm UTC](https://forum.inductiveautomation.com/t/cant-get-syntax-on-report-viewer-how-to-trigger-script-from-a-plc-tag-going-high-trigger/22545/8 "2019-02-13T16:25:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 13, 2019, 4:29pm UTC](https://forum.inductiveautomation.com/t/cant-get-syntax-on-report-viewer-how-to-trigger-script-from-a-plc-tag-going-high-trigger/22545/9 "2019-02-13T16:29:00Z")

</div>

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().
