# Passing an integer value from a script to report doesn't work

**URL:** <https://forum.inductiveautomation.com/t/passing-an-integer-value-from-a-script-to-report-doesnt-work/99135>\
**Category:** Ignition\
**Tags:** vision, reporting, scripting\
**Created:** [November 26, 2024, 5:32pm UTC](https://forum.inductiveautomation.com/t/passing-an-integer-value-from-a-script-to-report-doesnt-work/99135 "2024-11-26T17:32:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![SMarcin](https://avatars.discourse-cdn.com/v4/letter/s/8e8cbc/32.png) [@SMarcin](https://forum.inductiveautomation.com/u/SMarcin)\
**Post date:** [November 26, 2024, 5:32pm UTC](https://forum.inductiveautomation.com/t/passing-an-integer-value-from-a-script-to-report-doesnt-work/99135/1 "2024-11-26T17:32:34Z")

</div>

Hello,

I'm new to Ignition and I have an issue with reporting.

I have a report with Basic SQL Query as Data source:

```python
SELECT audit_events.
FROM audit_events
WHERE AUDIT_EVENTS_ID = :idValue

```

In project I choose idValue using Spinner component and pass it to a Button with a script attached to actionPerformed Event Handler to generate the report:

```python
selected_id = event.source.parent.getComponent('Spinner').intValue

settings = {"path":"C:\\Users\\kreek\\Desktop", "fileName":"Report.pdf", "format":"pdf", "idValue": selected_id}

system.report.executeAndDistribute(path="Audit Report", project="EFi", action="save", actionSettings=settings)

```

And the report comes out blank, without any data for some reason.

I also just for testing i tried it with  
`WHERE Date < :selectedDate`

Where selectedDate was a date from calendar component and it worked flawlessly.

Am i missing something?

---

<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:** [November 26, 2024, 6:00pm UTC](https://forum.inductiveautomation.com/t/passing-an-integer-value-from-a-script-to-report-doesnt-work/99135/2 "2024-11-26T18:00:16Z")

</div>

If you look at the function signature in the [manual](https://docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-report/system-report-executeAndDistribute), you'll see that parameters are not included in the action settings.

```python
selected_id = event.source.parent.getComponent('Spinner').intValue
parameters= {"idValue": selected_id}

settings = {
    "path":"C:\\Users\\kreek\\Desktop", 
    "fileName":"Report.pdf", 
    "format":"pdf"
}

system.report.executeAndDistribute(
    path="Audit Report", 
    project="EFi", 
    action="save", actionSettings=settings, 
    parameters=parameters
)

```

---

<div class="post-metadata">

**Author:** ![SMarcin](https://avatars.discourse-cdn.com/v4/letter/s/8e8cbc/32.png) [@SMarcin](https://forum.inductiveautomation.com/u/SMarcin)\
**Post date:** [November 26, 2024, 8:39pm UTC](https://forum.inductiveautomation.com/t/passing-an-integer-value-from-a-script-to-report-doesnt-work/99135/3 "2024-11-26T20:39:55Z")

</div>

Unfortunately that didn't fix the issue ☹

My current script:

```python
selected_id = event.source.parent.getComponent('Spinner').intValue
print selected_id

pars = {"idValue": selected_id}

settings = {
			"path":"C:\\Users\\kreek\\Desktop",
			"fileName":"Report.pdf",
			"format":"pdf"
			}

system.report.executeAndDistribute(
path="Audit Report",
project="EFi",
action="save",
actionSettings=settings,
parameters=pars)

```

My current Query:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/d/ede099abbbbddfec55659a944f0b2f078669c492.png)

I'm completely stuck. Hard-coding a value into a query works perfectly, but getting it from a component is not working for me at all.

---

<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:** [November 26, 2024, 8:44pm UTC](https://forum.inductiveautomation.com/t/passing-an-integer-value-from-a-script-to-report-doesnt-work/99135/4 "2024-11-26T20:44:33Z")

</div>

You are not using your parameter at all because it does not exist. You have to create the parameter, `idValue` in the report, not just the query.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/3/33a7799398936af0b85be53b09092de31a245d4f.png)

Example for Named Query source

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/f/7f5c7ca19bcd117ea93564e52b7dbe4eb5a200ff.png)

For query source, you use a `?` for the variable place holder, not the named query style `:intValue`. After you put in a question mark, a window will appear to choose the parameter to substitute into the query.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/9/f90cd5d34f2594db4599cdce368ef87fbbd60392.png)

---

<div class="post-metadata">

**Author:** ![SMarcin](https://avatars.discourse-cdn.com/v4/letter/s/8e8cbc/32.png) [@SMarcin](https://forum.inductiveautomation.com/u/SMarcin)\
**Post date:** [November 26, 2024, 9:05pm UTC](https://forum.inductiveautomation.com/t/passing-an-integer-value-from-a-script-to-report-doesnt-work/99135/5 "2024-11-26T21:05:22Z")

</div>

Solved! Thank you very much!

For anyone else wondering in the future:

I just had to add an empty parameter idValue:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/3/c381bee582e0752e3ab3e3925f76e9af58c3d6fb.png)

and change the way the parameter is being put in the query from  
`WHERE AUDIT_EVENTS_ID = :idValue `  
to  
`WHERE AUDIT_EVENTS_ID = {idValue}`

---

<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:** [November 26, 2024, 9:17pm UTC](https://forum.inductiveautomation.com/t/passing-an-integer-value-from-a-script-to-report-doesnt-work/99135/6 "2024-11-26T21:17:59Z")

</div>

Just to clarify, it does not need to be empty. If you supply a value in the report, it will be the default value if an overriding parameter is not used in the report execute function.
