Page 1 of 1

Dynamic URL in Genie charts

Posted: Tue Aug 16, 2016 9:32 am
by dustinmiles
When setting the dynamic URL property on a chart in genie, is it possible to make the URL variable? I would like to pass a parameter in the url (i.e. chart.php?var=MyVar) and have this be different based on conditions in the program. Is something like this possible?

Re: Dynamic URL in Genie charts

Posted: Tue Aug 16, 2016 2:20 pm
by Scott Klement
You can set any property with JavaScript code by starting that property with "script:". Genie will run the property through a JavaScript interpreter, and assign the output to the property.

So, for example, you could set the url to:

Code: Select all

script: "/path/to/chart.php?myVar=" + encodeURIComponent(get("D_1_20"))
Genie would retrieve a field with an ID of D_1_20, encode it so that it works nicely in a URL, and add it into the URL.

One thing that's important to consider is that these properties are activated when the screen loads, so any variables need to be set when the screen is sent to the display. That shouldn't be a problem if they are coming from the IBM i application.

Re: Dynamic URL in Genie charts

Posted: Tue Aug 16, 2016 5:27 pm
by dustinmiles
Yes, this is exactly what I was looking for. Thank you!