Get Free Trial

Slice As Variable

Scott Oliver asked on November 18, 2022


For a frustrating reason which I would rather not get into, we are in need of loading a report through a JS function.

The datasource, authentication and license keys can all be parsed through a variable which is fantastic.

However, when it comes to the slice and mapping (potentially format and condition too), we are unable to load it as a variable.

Could you please help us understand if it is possible to store the slice as a variable? I have seen a few examples where you can utilise the run query function, but it would be helpful if we could run it as per our function (attached).

Example Function.txt

3 answers

Solomiia Andrusiv Solomiia Andrusiv Flexmonster November 18, 2022

Hello, Scott!
Thank you for contacting us.
Kindly note that SliceObject as well as MappingObject have the JavaScript object datatype and be passed to the function as regular object variables.
We have prepared a JSFiddle example for illustration:
Could you please let us know if the suggested approach satisfies your needs?
Looking forward to hearing from you.

Scott Oliver November 19, 2022

Hello Solomiia,

Thank you so much for your prompt response!

Although I truly appreciate your input, I would like to try and pass these as variables for a button. For example an external button or command that triggers the report to load.

The moment I try and parse the map, I presume because of the quotes it breaks. I have even tried base encoding and decoding the mapping (see the attached).

Your input would be amazing.

Flex Example.html

Solomiia Andrusiv Solomiia Andrusiv Flexmonster November 21, 2022

Hello, Oliver!

Thank you for your response.

We kindly suggest the following approach to create Flexmonster instance using the button to trigger the creation function:

1. Add the onclick function without arguments to the button.

2. Inside the added function, extract the slice, mapping, and other parameters from where they are stored.
For example, get parameters that are changing dynamically from the endpoint using AJAX, or extract the static ones from the localStorage.

3. Run the LoadFlexmonster() function with already loaded parameters. Use JSON.parse() function if necessary.

Please note this is only one of the possible approaches, and your implementation may differ.

Hope you will find our answer helpful.


Please login or Register to Submit Answer