# Reporting module - specific scripting functions?

**URL:** <https://forum.inductiveautomation.com/t/reporting-module-specific-scripting-functions/1895>\
**Category:** Ignition\
**Created:** [June 3, 2010, 8:54pm UTC](https://forum.inductiveautomation.com/t/reporting-module-specific-scripting-functions/1895 "2010-06-03T20:54:42Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dravik](https://avatars.discourse-cdn.com/v4/letter/d/e274bd/32.png) [@Dravik](https://forum.inductiveautomation.com/u/Dravik)\
**Post date:** [June 3, 2010, 8:54pm UTC](https://forum.inductiveautomation.com/t/reporting-module-specific-scripting-functions/1895/1 "2010-06-03T20:54:42Z")

</div>

I was looking for some documentation on available scripting functions specific to the Report Viewer object. Specifically, I’d like to call the object to print the currently displayed report to the default printer the client system has.

I have already built the report, Loads when a lot number is entered into a text field. Wrote a quick script to pull the lot number from my furnace and place it into the text field once the load has finished quenching. Just looking for that last piece… 🙂

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [June 3, 2010, 11:00pm UTC](https://forum.inductiveautomation.com/t/reporting-module-specific-scripting-functions/1895/2 "2010-06-03T23:00:28Z")

</div>

Try:

`report = event.source.parent.getComponent("Report Viewer")
report.print(None, 0)`

---

<div class="post-metadata">

**Author:** ![Dravik](https://avatars.discourse-cdn.com/v4/letter/d/e274bd/32.png) [@Dravik](https://forum.inductiveautomation.com/u/Dravik)\
**Post date:** [June 4, 2010, 7:10pm UTC](https://forum.inductiveautomation.com/t/reporting-module-specific-scripting-functions/1895/3 "2010-06-04T19:10:01Z")

</div>

Cool thanks!

now is there a function to wait some number of millisecs before I move to the next command?

Or a way to tell that the report viewer has loaded the report and trigger the print off that?

---

<div class="post-metadata">

**Author:** ![Dravik](https://avatars.discourse-cdn.com/v4/letter/d/e274bd/32.png) [@Dravik](https://forum.inductiveautomation.com/u/Dravik)\
**Post date:** [June 4, 2010, 7:19pm UTC](https://forum.inductiveautomation.com/t/reporting-module-specific-scripting-functions/1895/4 "2010-06-04T19:19:43Z")

</div>

Or hmm, can I just do a system.util.invokeLater and call the print function after a small delay.

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [June 7, 2010, 4:09pm UTC](https://forum.inductiveautomation.com/t/reporting-module-specific-scripting-functions/1895/5 "2010-06-07T16:09:21Z")

</div>

Sure, you can use a delay to wait for the report to load. If you’re waiting for data to come in from a SQL query, you can put an event handler on the report’s propertyChanged event watching for your data variable(s) to change.

---

<div class="post-metadata">

**Author:** ![Dravik](https://avatars.discourse-cdn.com/v4/letter/d/e274bd/32.png) [@Dravik](https://forum.inductiveautomation.com/u/Dravik)\
**Post date:** [June 7, 2010, 4:28pm UTC](https://forum.inductiveautomation.com/t/reporting-module-specific-scripting-functions/1895/6 "2010-06-07T16:28:09Z")

</div>

Alrighty, I went with something like this

`if event.newValue != event.oldValue:	
	lotlength = event.newValue
	if lotlength > 5:
		def reportPrint13(report = event.source.parent.getComponent("Report Viewer")):
			report.print(None, 0)
		system.util.invokeLater(reportPrint13, 5000)
`

But I seem to be printing 2 copies, Anyone see where I went wrong?

---

<div class="post-metadata">

**Author:** ![Dravik](https://avatars.discourse-cdn.com/v4/letter/d/e274bd/32.png) [@Dravik](https://forum.inductiveautomation.com/u/Dravik)\
**Post date:** [June 7, 2010, 4:48pm UTC](https://forum.inductiveautomation.com/t/reporting-module-specific-scripting-functions/1895/7 "2010-06-07T16:48:15Z")

</div>

A touch more detail, I have a button configured to write the value into a client tag. The text property of the object the script above is running on is bound to the client tag.

---

<div class="post-metadata">

**Author:** ![Dravik](https://avatars.discourse-cdn.com/v4/letter/d/e274bd/32.png) [@Dravik](https://forum.inductiveautomation.com/u/Dravik)\
**Post date:** [June 7, 2010, 8:49pm UTC](https://forum.inductiveautomation.com/t/reporting-module-specific-scripting-functions/1895/8 "2010-06-07T20:49:18Z")

</div>

and never mind that too…

```auto
if event.propertyName == "text":
	if event.newValue != event.oldValue:	
		value = event.newValue
		lotlength = len(value)
		if lotlength > 5:
			def reportPrint13(report = event.source.parent.getComponent("Report Viewer")):
				report.print(None, 0)
			system.util.invokeLater(reportPrint13, 5000)
```

works a lot better… and 1 only get 1 copy per.  
Fancy that, Filtering like it tells me too in the documentation works… 😊

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [June 14, 2010, 5:48pm UTC](https://forum.inductiveautomation.com/t/reporting-module-specific-scripting-functions/1895/9 "2010-06-14T17:48:50Z")

</div>

Yeah, don’t feel bad, that gets everybody.

---

<div class="post-metadata">

**Author:** ![Dravik](https://avatars.discourse-cdn.com/v4/letter/d/e274bd/32.png) [@Dravik](https://forum.inductiveautomation.com/u/Dravik)\
**Post date:** [June 23, 2010, 7:45pm UTC](https://forum.inductiveautomation.com/t/reporting-module-specific-scripting-functions/1895/10 "2010-06-23T19:45:25Z")

</div>

If I need to print multiple copies would it be better to use a for loop or can I just pass the number of copies through the print() function?

---

<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:** [June 23, 2010, 7:52pm UTC](https://forum.inductiveautomation.com/t/reporting-module-specific-scripting-functions/1895/11 "2010-06-23T19:52:00Z")

</div>

You have to loop through printing more than one copy since you can’t pass in the copy count.
