Reporting module - specific scripting functions?

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… :slight_smile:

Try:

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

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?

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

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.

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?

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.

and never mind that too…

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… :blush:

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

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?

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