Generating a report from window components

I’m trying to generate reports based off parameters set by dropdown lists in windows (several queries reference these dropdown lists to generate multiple tables in the window. .Is it even possible for the report designer to reference components?

Assuming you are using the Report Viewer component on a vision window, yes you can bind a report parameter with a dataset type to the data property of a dropdown list.

1 Like

Is this only possible with a report viewer component within the window? I’d like to have it generated and downloaded off an event script on a button. As an example, one of the windows I have currently tracks parts per hour. I’d like to have a team leader able to select the start and end of shifts times and then generate an end of shift report from that.

Absolutely, in that case you will use system.report.executeAndDistribute and pass in the dataset as a parameter.

2 Likes

Thanks, I think I’ve almost got it figured out. However, I’m not 100% on how to pass the dataset off as a report parameter.

  1. Create a new parameter in the report with type Dataset:

  2. Create a script data source in the report and manipulate the datasource however you want. Here I’m just passing the parameter through:

  3. Do something in the report with the new data source:

  4. Add script to button:

params = {"DatasetParameter": event.source.parent.getComponent('Power Table').data}
settings = {"path":"C:\\Ignition Reports", "fileName":"Report.pdf", "format":"pdf"}
system.report.executeAndDistribute("myReport", "myProject", parameters=params, action="save", actionSettings=settings)

1 Like

Thanks for the help. I’m getting an error

com.inductiveautomation.ignition.client.gateway_interface.GatewayException: com.inductiveautomation.ignition.client.gateway_interface.GatewayException: ImportError: No module named factorypmi

Do I need to import something for this function?

It seems to be an issue related to passing the parameter.

post your code with triple back quotes one line before and one line after your code for formatting

Spoke with Brendan on the phone about this. The dataset he was passing to his report was generated by a sql query binding on the data property of a power table. This binding had the ‘Retain Rows’ options disabled. When unchecked, this binding actually returns a NonSerializingDataset (and not a BasicDataset like the report parameter is expecting). There are two options to avoid this: 1) enable Retain rows or 2) convert the NonSerializingDataset by importing BasicDataset from com.inductiveautomation.ignition.common.

2 Likes