How to manage multiple message in one node(function node)

Hello,
I am very new to node red and programming and I have a project to do.
The project is that we have options to select and based to these selections we will have an output in the dashboard.
The options are in a CSV file.
Here is the CSV file shape :

A,p1,c1,s1
A,p2,c2,s2
B,p3,c3,s3
C,p4,c4,s4
C,p5,c5,s5

==================================================================
what I did till now is to create a dropdown list in the first tab from this CSV file(column 1)
then when we select from the dropdown list we go to the corresponding tab (Tab A, B or C). There we have another dropdown list (items from column 2) and we select an item.

Now I want to print a value of column 4 corresponding to the selected items.
For example if the user select A at first tab then he select p2 at second dropdown list the message to appear should be s2.

==============================================================

flows (1).json (9.7 KB)

If there is a simple way, please tell me.
I have an idea in my mind, but I need to read msg.payload from two different nodes(dropdown and CSV node) and compare them together.
The problem is that I don't know have to say to read two msg.payload in the function.
like
msg.payload 1 --> is from dropdown list node.
msg.payload 2 --> is from CSV node.

See this article in the cookbook for an example of how to join messages into one object.

Once both values are in one payload, you can compare using a function node or switch node.

Use debug node to get path to values.

There’s a great page in the docs that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

BX00Cy7yHi

https://nodered.org/docs/user-guide/messages


Lastly, as you Are new here...

I recommend watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

You can pass the csv data along with the picked option, so later on you can then used the data to retreive the output.
here is an example.

[{"id":"b86f186e.375008","type":"inject","z":"1378ba83.90c825","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":410,"y":560,"wires":[["9c36a63e.ed4cd8"]]},{"id":"9c36a63e.ed4cd8","type":"template","z":"1378ba83.90c825","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"A,p1,c1,s1\nA,p2,c2,s2\nB,p3,c3,s3\nC,p4,c4,s4\nC,p5,c5,s5\n","output":"str","x":570,"y":560,"wires":[["2c9b985e.e5c3c"]]},{"id":"2c9b985e.e5c3c","type":"csv","z":"1378ba83.90c825","name":"","sep":",","hdrin":false,"hdrout":"all","multi":"mult","ret":"\\r\\n","temp":"","skip":"0","strings":false,"include_empty_strings":"","include_null_values":"","x":710,"y":560,"wires":[["b024df04.dddbd8"]]},{"id":"b024df04.dddbd8","type":"change","z":"1378ba83.90c825","name":"","rules":[{"t":"set","p":"options","pt":"msg","to":"$distinct($$.payload.col1).{\t   \"Type \" & $: {\t   \"o1\":$,\t   \"data\":$$.payload\t   }\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":880,"y":560,"wires":[["b39b85bc.5155d","5f8e252.3017e5c"]]},{"id":"b39b85bc.5155d","type":"ui_dropdown","z":"1378ba83.90c825","name":"","label":"","tooltip":"","place":"Select option","group":"6e33f3db.defabc","order":1,"width":0,"height":0,"passthru":false,"multiple":false,"options":[],"payload":"","topic":"","topicType":"str","x":430,"y":640,"wires":[["96f97e67.d78458"]]},{"id":"5f8e252.3017e5c","type":"debug","z":"1378ba83.90c825","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"options","targetType":"msg","statusVal":"","statusType":"auto","x":960,"y":640,"wires":[]},{"id":"96f97e67.d78458","type":"change","z":"1378ba83.90c825","name":"","rules":[{"t":"set","p":"options","pt":"msg","to":"[\t   $$.payload.data[col1=$$.payload.o1].col2\t.{\t   $: {\t       \"o1\": $$.payload.o1,\t       \"o2\": $,\t       \"data\": $$.payload.data\t   }\t}]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":640,"wires":[["5f8e252.3017e5c","3c9e55c9.f0d60a"]]},{"id":"3c9e55c9.f0d60a","type":"ui_dropdown","z":"1378ba83.90c825","name":"","label":"","tooltip":"","place":"Select option","group":"6e33f3db.defabc","order":0,"width":0,"height":0,"passthru":false,"multiple":false,"options":[],"payload":"","topic":"","topicType":"str","x":430,"y":720,"wires":[["8ce240ac.a5fad8"]]},{"id":"8ce240ac.a5fad8","type":"change","z":"1378ba83.90c825","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$$.payload.data[\t   col1=$$.payload.o1 and  col2 = $$.payload.o2\t].col4","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":720,"wires":[["4ca608a0.3d1d8"]]},{"id":"4ca608a0.3d1d8","type":"ui_text","z":"1378ba83.90c825","group":"6e33f3db.defabc","order":0,"width":0,"height":0,"name":"","label":"","format":"{{msg.payload}}","layout":"row-spread","x":820,"y":760,"wires":[]},{"id":"6e33f3db.defabc","type":"ui_group","name":"problems","tab":"8f03e639.85956","order":4,"disp":true,"width":"6","collapse":false},{"id":"8f03e639.85956","type":"ui_tab","name":"Home","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

Thanks a lot.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.