7.8 Report Printing

I know we can schedule a new report to print.

Is there a way to auto print the report on a trigger and ignore the schedule?

Below is the code I am trying - but in the console I get an error “No Print Service Found”

#This will print the current report when the button is pushed.
settings = {“copies”:1, “printBothSides”:True, “collate”: True}
system.report.executeAndDistribute(path=“Report1”, project=“TestReports”, action= “print”, actionSettings = settings)

Yes, you can use the system.report.executeAndDistribute() script function to print from a script:

docs.inductiveautomation.com:84 … +Functions

edit: whoops, posted before I saw your followup. I assume you are able to print ok outside of the script?

edit 2: Doesn’t look like you have named a printer to print to in your settings. Take a look at the script function documentation, try setting the value for “primaryPrinterName”. Your system may not be picking up the default correctly.

I tried that as well before I posted. I took it out to see if it would just print to the default printer -

Should the printer name be exactly what it is in Windows “Device and Printers”

It’s going to be the same as whatever the Gateway has. Remember that these scripts are run as Gateway services, so you want to make sure that whatever printer you are trying to use is available to your gateway.