Passing Commands to Embedded Reports

image_pdfimage_print

Jedox reports can be embedded in external web applications. It is also possible for the external web application to set values for @variables in the Jedox report.
For this, you can either append parameters to the report’s URL or use the postMessage Web API in JavaScript code.

URL with passing variables

To find the URL of a report on a server, right-click on a report (user preview), select Properties, and open the Link tab. If this report has the variables  “year”,  “region”, and “product”, and all of them are not private, then you can pass variables with the URL as follows: <URL>&var/year=2009&var/region=West&var/product=Monitors

Example:

<URL>/ui/studio/user=paloinsider&pass=S8CqA&var/year=2009&var/region=West&var/product=Monitors

Calling commands from external sources using postMessage API

You can call commands into Jedox Web from external sources, such as pages where a Jedox Report is embedded. This can be done using the postMessage API. With this option you can, for example, allow setting a session variable to a specific value using JavaScript in an external environment. The advantage of using this method is that, instead of reloading the full report in the iframe, it only sets the value of the session variable.

Note: for security reasons, restrict the postMessage to be accepted only from specific, trusted environments.

Before the  postMessage API can be used, it must be enabled in Jedox Web Settings, as described in the steps below:

  1. Go to Jedox Web > Administration > Settings and click Add key. Fill in the fields as shown below (description is optional) and click OK:

  2. Add another key and fill in as shown below, using your own URI(s) in the Value field:

    Click OK. PostMessage API is now enabled on the Jedox host. The Administration area shows the two new keys:

Example postMessage script

In this example, there are two hosts. Host A (https://from.mydomain.com) runs a web application that will post the message. Host B (https://to.mydomain.com) runs Jedox. The postMessage API has been enabled on Host B (Jedox) as described in the steps above.

The sample script below, running on a page on https://from.mydomain.com, would set the value of the session variable Year to 2018 inside the Jedox report served from https://to.mydomain.com. In other words, it would send a postMessage to an element with the ID “jedox”:

<iframe id="jedox" width="80%" height="80%" src="https://to.mydomain.com/ui/lnk/?_=eJxNkD9vg0AMxb8K8oxg6cScpZUitcrKc...">

document.getElementById('jedox').contentWindow.postMessage( [ ['svar', 'Year', 2018] ], 'https://from.mydomain.com');

For more information on web messaging APIs, see https://en.wikipedia.org/wiki/Web_Messaging.

image_pdfimage_print