Printing Report Data Missing

Ignition 7.8.3

Window has a report viewer and “print” button. The print button fills in some of the properties on the report then uses the “.print()” method to print the report. Most (perhaps all) of the time, the report data generated from the properties does not show up on the report.

I must be missing something pretty simple… What is it?

Thanks,
Mack

The .print() method on the report viewer doesn’t wait for the content to update – it prints whatever you have at that instant. And since property assignment is in the foreground, the viewer can’t act on your assignments until after your event method completes. Use system.util.invokeLater() to call the .print() method a second or so later.

Thanks Phil.

I tried wrapping the print statement in invokeLater, but did not have a delay…Would it make sense to watch .isValid during the delay?

I never needed to. But it might be helpful if you try for short delays. Be sure not to sleep – just re-invoke with another delay if not valid.

Would it be easier to use system.report.ExecuteAndDistribute(). This would ensure that the report data is updated when you feed it the parameters.

	system.report.executeAndDistribute(path=report, 
	project='ProjectName',
	parameters = params,
	action='print', 
	actionSettings = {'primaryPrinterName':PrinterName,
	'copies':1})

It would be, except the printers are not available from the gateway…