81
Views
2
Comments
Solved
How to pass input parameter to javascript function?
Application Type
Reactive

I'm creating the custom highcharts. Default js code has sample json content inside. I have converted my table data to js readable json format.

I have marked the hard coded value, there I want to pass the converted data

So, I'm taking an input parameter and passing the data thru it like the below image,

I get the below error,

Please help me.

Solution

Hello Kumar!
I had a similar issue when trying to transition from a hardcoded JSON into an input parameter inside of a JavaScript node.

It didn't work because the hardcoded JSON looked like this:

And the input parameter was a local variable of type Text that looked like this:

So this is what I had to do:
1) Create a structure with the fields that the JSON has

2) Create a variable, that is a list of the structure

3) Use JSONDeserialize

4) Use ListAppendAll

5) Use JSONSerialize

6) Pass the JSONSerialize.Json as an input parameter to the JavaScript node

7) Inside the JavaScript node, use JSON.parse() to generate a JSON object from a JSON string


Solution

Hello Kumar!
I had a similar issue when trying to transition from a hardcoded JSON into an input parameter inside of a JavaScript node.

It didn't work because the hardcoded JSON looked like this:

And the input parameter was a local variable of type Text that looked like this:

So this is what I had to do:
1) Create a structure with the fields that the JSON has

2) Create a variable, that is a list of the structure

3) Use JSONDeserialize

4) Use ListAppendAll

5) Use JSONSerialize

6) Pass the JSONSerialize.Json as an input parameter to the JavaScript node

7) Inside the JavaScript node, use JSON.parse() to generate a JSON object from a JSON string


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.