# Dynamically Getting/Setting Report Parameters

**URL:** <https://forum.inductiveautomation.com/t/dynamically-getting-setting-report-parameters/16825>\
**Category:** Ignition\
**Tags:** scripting, ignition79\
**Created:** [January 31, 2018, 6:08pm UTC](https://forum.inductiveautomation.com/t/dynamically-getting-setting-report-parameters/16825 "2018-01-31T18:08:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bfuson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bfuson/32/4597_2.png) [@bfuson](https://forum.inductiveautomation.com/u/bfuson)\
**Post date:** [January 31, 2018, 6:08pm UTC](https://forum.inductiveautomation.com/t/dynamically-getting-setting-report-parameters/16825/1 "2018-01-31T18:08:43Z")

</div>

I’m trying to build a generic window that allows users to select and configure reports to run.  
I have a selector component that lists the available reports and sets the path on a Report Viewer component.  
Now I’m trying to generate input components based on the parameters of the chosen report, and am having some difficulties getting the names and types of the dynamic properties available to me.

After reading [this post](http://forum.inductiveautomation.com/t/get-list-of-report-parameters/12568) I can get the list of dynamic props as a `java.util.Treemap` using `getDynamicProps()`, but I can’t seem to get/set the report parameters.

I can’t access it as a dict in jython:  
`props['Date']` returns a None

Nor directly through the property:  
`get('Date')` returns a None

Though strangely, when trying `put('Date', system.date.now())` I get a type mismatch since it’s expecting a `DynamicPropertyDescriptor`, not the type of the property… But if that’s the case, shouldn’t my attempts at reading the property yield that type even when the underlying parameter is unset?

Not sure if I’m going about this all wrong, but I need to get the names+types of report parameters and hopefully set them.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 31, 2018, 6:25pm UTC](https://forum.inductiveautomation.com/t/dynamically-getting-setting-report-parameters/16825/2 "2018-01-31T18:25:52Z")

</div>

Try printing the `.keySet()` from the treemap to see what you really have. You may find it helpful to browse the JavaDoc for these [methods](http://files.inductiveautomation.com/sdk/javadoc/ignition79/793/com/inductiveautomation/vision/api/client/components/model/AbstractVisionComponent.html#getDynamicProps--) and [objects](https://docs.oracle.com/javase/8/docs/api/java/util/TreeMap.html).

---

<div class="post-metadata">

**Author:** ![bfuson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bfuson/32/4597_2.png) [@bfuson](https://forum.inductiveautomation.com/u/bfuson)\
**Post date:** [January 31, 2018, 7:03pm UTC](https://forum.inductiveautomation.com/t/dynamically-getting-setting-report-parameters/16825/3 "2018-01-31T19:03:35Z")

</div>

Thank you for the prompt reply and helpful info, though it's still not clear to me where I'm going wrong.

Here's my logging code:

> `	props = event.source.getDynamicProps() date = props[str('Date')] logger = system.util.getLogger("DEV") logger.info(str(props.keySet())) logger.info(str(date)) logger.info(str(date.getPropertyType())) logger.info(str(date.getPropertyValue()))`

Which produces this output:

> `13:54:35.528 [AWT-EventQueue-2] INFO DEV - [Date, EndDate, StartDate] 13:54:35.529 [AWT-EventQueue-2] INFO DEV - Date 13:54:35.530 [AWT-EventQueue-2] INFO DEV - <type 'java.lang.String'>`  
> and then errors...

I'm calling the above code from the propertyChange event script on the reportviewer, which only fires for the propertyName 'reportPath'. Weirdly, I get the above output when I switch _off_ from the report I'm concerned with (to an essentially blank one). I'd expect to see that log info when I switch onto the right report.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 31, 2018, 7:16pm UTC](https://forum.inductiveautomation.com/t/dynamically-getting-setting-report-parameters/16825/4 "2018-01-31T19:16:04Z")

</div>

If you really have unindented code in a propertyChange script, remove it. There can be all kinds of weirdness if you don’t have all of your code nested in an appropriate  
`if event.propertyName == 'someName':` code block.  
And it is likely too soon after switching to a particular report to expect the custom properties to be established – that requires deserializing the template definition. Place your code in a separate button’s actionPerformed event so that you know it runs correctly. After that, you can automate further with system.util.invokeLater() to get an appropriate delay.

Meanwhile, show the error you get when getPropertyValue() fires. Consider just using the component’s getPropertyValue() method instead of the descriptor’s method once you have the name to look up.

---

<div class="post-metadata">

**Author:** ![bfuson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bfuson/32/4597_2.png) [@bfuson](https://forum.inductiveautomation.com/u/bfuson)\
**Post date:** [January 31, 2018, 7:48pm UTC](https://forum.inductiveautomation.com/t/dynamically-getting-setting-report-parameters/16825/5 "2018-01-31T19:48:34Z")

</div>

The propertyChange event code isn’t unindented and is under a similar conditional (“reportPath”). I mentioned that but should have put it in my code block for clarity. Sorry about that.

Firing the getProps code by a button does resolve that timing-related issue, and as a result getPropertyType does return the correct type now (Date whereas before it was String). I was also using getPropertyValue on the treemap descriptor typed value instead of getValue. 😥

For completeness, here’s the error I got before:  
`AttributeError: 'NoneType' object has no attribute 'getPropertyType'`

The resources you linked and timing insight fixed my problem, thank you Phil!

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [October 1, 2018, 9:18pm UTC](https://forum.inductiveautomation.com/t/dynamically-getting-setting-report-parameters/16825/6 "2018-10-01T21:18:56Z")

</div>

I’m attempting to do the same thing as yourself… once you have the correct values in the treemap how did you shove it all back into the report and have the report update itself to reflect the new parameter values?

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [October 2, 2018, 12:07pm UTC](https://forum.inductiveautomation.com/t/dynamically-getting-setting-report-parameters/16825/7 "2018-10-02T12:07:44Z")

</div>

OK… never mind on this. I slept and figured it out. After setting the values call loadReport on the report viewer.
