Dynamic URL in Genie charts

Use this board to ask questions or have discussions with other Genie users.
Post Reply
dustinmiles
New User
Posts: 13
Joined: Mon Aug 15, 2016 6:24 pm
First Name: Dustin
Last Name: Miles
Company Name: Unipres USA
Contact:

Dynamic URL in Genie charts

Post 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?
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Dynamic URL in Genie charts

Post 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.
dustinmiles
New User
Posts: 13
Joined: Mon Aug 15, 2016 6:24 pm
First Name: Dustin
Last Name: Miles
Company Name: Unipres USA
Contact:

Re: Dynamic URL in Genie charts

Post by dustinmiles »

Yes, this is exactly what I was looking for. Thank you!
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests