Need a special offer?Find out if your project fits.
+

Slice As Variable

Answered
Scott Oliver asked on November 18, 2022

Hello,

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).

Attachments:
Example Function.txt

6 answers

Public
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: https://jsfiddle.net/flexmonster/xzkgcufh/.
 
Could you please let us know if the suggested approach satisfies your needs?
 
Looking forward to hearing from you.
 
Regards,
Solomiia

Public
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.

Attachments:
Flex Example.html

Public
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.

Regards,
Solomiia

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster November 29, 2022

Hello, Oliver!

Hope you are doing well.

Our team is wondering if you had a chance to create the Flexmonster instance using the approach we suggested in the previous answer.
Could you please let us know if it works for your case?

Looking forward to hearing from you.

Regards,
Solomiia

Public
Scott Oliver November 30, 2022

Hello,

Thanks for checking in. Yes, we were able to have success by JSON parsing the data, after we had formatted our slice and mapping objects to include the appropriate quotations.

Thanks for your assistance.

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster November 30, 2022

Hello, Scott!

Thank you for your feedback.

We are glad to hear that the suggested approach was helpful.

Feel free to contact us in case of any other questions.

Regards,
Solomiia

Please login or Register to Submit Answer