94
Views
5
Comments
Solved
Error input Parameter in JavaScript. [Error: a.forEach is not a function]
Application Type
Traditional Web, Reactive

Hello. 
As you can see in the images I am trying to send two text variables to the Java script, but this gives me an error. how can I solve that. what am I doing wrong?.
The OLM is Attachments.




NodosCanvasJS.oml
2024-01-04 15-15-51
Abed Al Banna
Solution

Hello @Erick Narvaez 

The issue with the JS is that you are passing the data as a string to the "addPaths" while it's expecting an array.


Here's how to fix it:

1. Add an additional [] to the data you have in the default value of MatrizNodosPlano:

 "[ ['Siebel', 'BUS', 'Registro Trafico[REG-TRF]'], 

          ['SAP R3', 'BUS'],

          ['APIM', 'BUS'],

          ['BUS', 'OIC'] ]"


2. Modify your JS as follows:

var paths = $parameters.MatrizNodosPlano.replace(/'/g, '"');

paths = JSON.parse(paths);

var c = new flowjs.DiGraph();

c.addPaths(paths);


3. Use the "eval()" function to execute a string as a code snippet:

eval($parameters.ConfigNodos);


The remaining part of the code can remain the same. I will attach it as an OML.

I hope this helps!


Best regards,

Abed

NodosCanvasJS.oml
2024-12-02 12-15-17
Aravind EONE

Great I learned something new today. eval()

2024-01-04 15-15-51
Abed Al Banna
UserImage.jpg
Erick Narvaez


@Abed Al Banna 

Thank you very much.. it was very useful. God bless you


2024-12-02 12-15-17
Aravind EONE

Hi @Erick Narvaez,

Is there only these 3 types or more to come? 

If it is only these 3 items, then you can pass the Link and color as input Instead of this whole code. 

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