# Request Help Printing a report

**URL:** <https://forum.inductiveautomation.com/t/request-help-printing-a-report/4195>\
**Category:** Archived Topics\
**Created:** [March 22, 2012, 5:06pm UTC](https://forum.inductiveautomation.com/t/request-help-printing-a-report/4195 "2012-03-22T17:06:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrtweaver](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@mrtweaver](https://forum.inductiveautomation.com/u/mrtweaver)\
**Post date:** [March 22, 2012, 5:06pm UTC](https://forum.inductiveautomation.com/t/request-help-printing-a-report/4195/1 "2012-03-22T17:06:10Z")

</div>

I have a report that I have designed. every 5min I have a timer that checks to see if it is time to print the report.

Can I, from within the timer script, using a if clause, print the report?

Here is the code I have tried.

```auto
z= fpmi.tag.getTagValue('[]pc')
y= fpmi.tag.getTagValue('[]print_lock')
print y,z
if z == 1 and y==1:
	fpmi.tag.writeToTag('[]pc',0)
	fpmi.tag.writeToTag('[]print_lock',0)
	job = fpmi.print.createPrintJob(event.source.parent.getComponent('Report'))
	job.print(none,0)
	job1 = fpmi.print.createPrintJob(event.source.parent.getComponent('Report1'))
	job1.print(none,0)

else:	
	print "no"
```

I am sure it is probably something stupidly simple staring right at me. Or who knows maybe the idea can not be done in the way I am trying. That is why I am hoping the experts on here will let me know.

The error message I get when I run the above timer script is as follows:

Traceback (innermost last):  
File “\<TimerScript:update (15000) [Delay, Shared]\>”, line 8, in ?  
NameError: event

```
at org.python.core.Py.NameError(Py.java)
at org.python.core.PyFrame.getglobal(PyFrame.java)
at org.python.core.PyFrame.getname(PyFrame.java)
at org.python.pycode._pyx225.f$0(<TimerScript:update (15000) [Delay, Shared]>:8)
at org.python.pycode._pyx225.call_function(<TimerScript:update (15000) [Delay, Shared]>)
at org.python.core.PyTableCode.call(PyTableCode.java)
at org.python.core.PyCode.call(PyCode.java)
at org.python.core.Py.runCode(Py.java)
at com.inductiveautomation.factorypmi.application.script.ScriptManager.runCode(ScriptManager.java:245)
at com.inductiveautomation.factorypmi.application.script.TimerScriptTask.run(TimerScriptTask.java:63)
at java.util.TimerThread.mainLoop(Unknown Source)
at java.util.TimerThread.run(Unknown Source)

```

FactoryPMI v3.3.1 (build 2549)  
Java: Sun Microsystems Inc. 1.6.0\_04

Thanks and have a great day.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [March 22, 2012, 5:35pm UTC](https://forum.inductiveautomation.com/t/request-help-printing-a-report/4195/2 "2012-03-22T17:35:59Z")

</div>

You don’t have the event object for client event scripts. They only exist on event handlers on components. You should either put a timer component on the window or try to get the window first:`z= fpmi.tag.getTagValue('[]pc')
y= fpmi.tag.getTagValue('[]print_lock')
print y,z
if z == 1 and y==1:
   fpmi.tag.writeToTag('[]pc',0)
   fpmi.tag.writeToTag('[]print_lock',0)
   rc = fpmi.gui.getWindow("WindowThatReportIsOn").getRootContainer()
   job = fpmi.print.createPrintJob(rc.getComponent('Report'))
   job.print(none,0)
   job1 = fpmi.print.createPrintJob(rc.getComponent('Report1'))
   job1.print(none,0)
else:   
   print "no"`

---

<div class="post-metadata">

**Author:** ![mrtweaver](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@mrtweaver](https://forum.inductiveautomation.com/u/mrtweaver)\
**Post date:** [March 26, 2012, 3:10pm UTC](https://forum.inductiveautomation.com/t/request-help-printing-a-report/4195/3 "2012-03-26T15:10:50Z")

</div>

Travis, thank you for the assistance on this. It worked as planned.

Now I only have one other question.

Is there a way to simulate a button click from within this same lines of code?

I have tried the doClick command it errors with the information the doClick is not a valid statement or something like that.

![:prayer:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/e5a7e3b63facc151ea73e3b45db7bdb3d4bdc316.gif ":prayer:")

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [March 26, 2012, 11:01pm UTC](https://forum.inductiveautomation.com/t/request-help-printing-a-report/4195/4 "2012-03-26T23:01:21Z")

</div>

You can force a button to click by using the following:`event.source.parent.getComponent("Button").doClick()`
