# Generating a report from window components

**URL:** <https://forum.inductiveautomation.com/t/generating-a-report-from-window-components/20332>\
**Category:** Ignition\
**Created:** [October 23, 2018, 8:58pm UTC](https://forum.inductiveautomation.com/t/generating-a-report-from-window-components/20332 "2018-10-23T20:58:22Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![brendan.curran](https://avatars.discourse-cdn.com/v4/letter/b/cdc98d/32.png) [@brendan.curran](https://forum.inductiveautomation.com/u/brendan.curran)\
**Post date:** [October 23, 2018, 8:58pm UTC](https://forum.inductiveautomation.com/t/generating-a-report-from-window-components/20332/1 "2018-10-23T20:58:22Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ethomason](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ethomason/32/43338_2.png) [@ethomason](https://forum.inductiveautomation.com/u/ethomason)\
**Post date:** [October 23, 2018, 9:01pm UTC](https://forum.inductiveautomation.com/t/generating-a-report-from-window-components/20332/2 "2018-10-23T21:01:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![brendan.curran](https://avatars.discourse-cdn.com/v4/letter/b/cdc98d/32.png) [@brendan.curran](https://forum.inductiveautomation.com/u/brendan.curran)\
**Post date:** [October 23, 2018, 9:08pm UTC](https://forum.inductiveautomation.com/t/generating-a-report-from-window-components/20332/3 "2018-10-23T21:08:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ethomason](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ethomason/32/43338_2.png) [@ethomason](https://forum.inductiveautomation.com/u/ethomason)\
**Post date:** [October 23, 2018, 9:10pm UTC](https://forum.inductiveautomation.com/t/generating-a-report-from-window-components/20332/4 "2018-10-23T21:10:54Z")

</div>

Absolutely, in that case you will use [system.report.executeAndDistribute](https://docs.inductiveautomation.com/display/DOC79/system.report.executeAndDistribute) and pass in the dataset as a parameter.

---

<div class="post-metadata">

**Author:** ![brendan.curran](https://avatars.discourse-cdn.com/v4/letter/b/cdc98d/32.png) [@brendan.curran](https://forum.inductiveautomation.com/u/brendan.curran)\
**Post date:** [October 23, 2018, 9:35pm UTC](https://forum.inductiveautomation.com/t/generating-a-report-from-window-components/20332/5 "2018-10-23T21:35:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ethomason](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ethomason/32/43338_2.png) [@ethomason](https://forum.inductiveautomation.com/u/ethomason)\
**Post date:** [October 23, 2018, 9:51pm UTC](https://forum.inductiveautomation.com/t/generating-a-report-from-window-components/20332/6 "2018-10-23T21:51:31Z")

</div>

1. Create a new parameter in the report with type Dataset:  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/a/a997c1bb5b47f04f8c811a0ab93ff068a4e50fe6.png)

2. Create a script data source in the report and manipulate the datasource however you want. Here I’m just passing the parameter through:  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/e/ed226bc102153b1bb67b6e02693b0dacc934ddfe.png)

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

4. Add script to button:

```auto
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)

```

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/5/5f0501015c197371ceb81cee378833c4fd5f9ed3.png)

---

<div class="post-metadata">

**Author:** ![brendan.curran](https://avatars.discourse-cdn.com/v4/letter/b/cdc98d/32.png) [@brendan.curran](https://forum.inductiveautomation.com/u/brendan.curran)\
**Post date:** [October 25, 2018, 2:43pm UTC](https://forum.inductiveautomation.com/t/generating-a-report-from-window-components/20332/7 "2018-10-25T14:43:02Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![brendan.curran](https://avatars.discourse-cdn.com/v4/letter/b/cdc98d/32.png) [@brendan.curran](https://forum.inductiveautomation.com/u/brendan.curran)\
**Post date:** [October 25, 2018, 3:24pm UTC](https://forum.inductiveautomation.com/t/generating-a-report-from-window-components/20332/8 "2018-10-25T15:24:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [October 25, 2018, 5:21pm UTC](https://forum.inductiveautomation.com/t/generating-a-report-from-window-components/20332/9 "2018-10-25T17:21:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bfreitas](https://avatars.discourse-cdn.com/v4/letter/b/9fc348/32.png) [@bfreitas](https://forum.inductiveautomation.com/u/bfreitas)\
**Post date:** [October 25, 2018, 6:24pm UTC](https://forum.inductiveautomation.com/t/generating-a-report-from-window-components/20332/10 "2018-10-25T18:24:17Z")

</div>

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.
