Hello everyone I am fairly new to Node-RED and this is my first post on the forums! I found a similar problem, but it was a bit more simple and didn't work for my problem.
I have two dropdowns that the user will select in a dashboard (from the CSV column A and column C). My goal is for when the user makes the selection, it will search the CSV for a row that matches the inputs, and has a output of the matching value in column D.
Here is an example of the CSV:
Here is the code:
[
{
"id": "df663e090db235b9",
"type": "file in",
"z": "9b03cc7ebfdc5189",
"name": "config_line",
"filename": "/home/dev/secured/ShippingStandards.csv",
"format": "utf8",
"chunk": false,
"sendError": false,
"encoding": "none",
"allProps": false,
"x": 330,
"y": 840,
"wires": [
[
"25c2bd2842ef3426"
]
]
},
{
"id": "25c2bd2842ef3426",
"type": "csv",
"z": "9b03cc7ebfdc5189",
"name": "",
"sep": ",",
"hdrin": true,
"hdrout": "all",
"multi": "mult",
"ret": "\\n",
"temp": "",
"skip": "0",
"strings": true,
"include_empty_strings": false,
"include_null_values": false,
"x": 490,
"y": 840,
"wires": [
[
"a30ac88d9fdf90b4",
"b99a78f1014f5d24",
"da6d3fe21d3b98b3"
]
]
},
{
"id": "ca84b1bc12776c8c",
"type": "inject",
"z": "9b03cc7ebfdc5189",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"topic": "",
"payloadType": "date",
"x": 140,
"y": 840,
"wires": [
[
"df663e090db235b9"
]
]
},
{
"id": "253a33f4844238a1",
"type": "ui_dropdown",
"z": "9b03cc7ebfdc5189",
"name": "Drop Down Order Type Code Description",
"label": "Order Type Code Description",
"tooltip": "",
"place": "Select option",
"group": "1c2e0ff9fd3d33d8",
"order": 2,
"width": 0,
"height": 0,
"passthru": true,
"multiple": false,
"options": [],
"payload": "",
"topic": "topic",
"topicType": "msg",
"className": "",
"x": 1240,
"y": 840,
"wires": [
[
"6d465fa8d382fc24"
]
]
},
{
"id": "a30ac88d9fdf90b4",
"type": "change",
"z": "9b03cc7ebfdc5189",
"name": "",
"rules": [
{
"t": "set",
"p": "options",
"pt": "msg",
"to": "$.payload.\"Order Type Code Description\"",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 700,
"y": 840,
"wires": [
[
"c0306414ac84339a",
"2384ab8e6fc4f9c6"
]
]
},
{
"id": "b99a78f1014f5d24",
"type": "debug",
"z": "9b03cc7ebfdc5189",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 670,
"y": 700,
"wires": []
},
{
"id": "7b03f23ec5902921",
"type": "comment",
"z": "9b03cc7ebfdc5189",
"name": "Drop Down to Select Task",
"info": "",
"x": 730,
"y": 800,
"wires": []
},
{
"id": "c0306414ac84339a",
"type": "function",
"z": "9b03cc7ebfdc5189",
"name": "Delete Duplicated Items",
"func": "var items = msg.options\nlet unique = [ ...new Set(items)]\n\nmsg.options = unique\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 930,
"y": 840,
"wires": [
[
"253a33f4844238a1",
"fccf5c6f1fbdd6d4"
]
]
},
{
"id": "65ae502f0333ca70",
"type": "comment",
"z": "9b03cc7ebfdc5189",
"name": "Read CSV File \"Standards\"",
"info": "",
"x": 110,
"y": 700,
"wires": []
},
{
"id": "0aebf24c316dea36",
"type": "comment",
"z": "9b03cc7ebfdc5189",
"name": "msg.payload = selected task",
"info": "",
"x": 1540,
"y": 840,
"wires": []
},
{
"id": "fdb87e35622d251e",
"type": "ui_dropdown",
"z": "9b03cc7ebfdc5189",
"name": "Drop Down Number of Employees on Packing Line",
"label": "Number of Employees on Packing Line",
"tooltip": "",
"place": "Select option",
"group": "1c2e0ff9fd3d33d8",
"order": 2,
"width": 0,
"height": 0,
"passthru": true,
"multiple": false,
"options": [],
"payload": "",
"topic": "topic",
"topicType": "msg",
"className": "",
"x": 1270,
"y": 960,
"wires": [
[
"800d04b48c778463"
]
]
},
{
"id": "ee50b68f4e1b9d79",
"type": "comment",
"z": "9b03cc7ebfdc5189",
"name": "Drop Down to Select # of Employees",
"info": "",
"x": 760,
"y": 920,
"wires": []
},
{
"id": "a61798580ae3ef30",
"type": "function",
"z": "9b03cc7ebfdc5189",
"name": "Delete Duplicated Items",
"func": "var items = msg.options\nlet unique = [ ...new Set(items)]\n\nmsg.options = unique\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 930,
"y": 960,
"wires": [
[
"fdb87e35622d251e",
"f5edf549bac85543"
]
]
},
{
"id": "49415244fb05dd4d",
"type": "comment",
"z": "9b03cc7ebfdc5189",
"name": "msg.payload = selected task",
"info": "",
"x": 1600,
"y": 960,
"wires": []
},
{
"id": "1c40ee1352c943b0",
"type": "debug",
"z": "9b03cc7ebfdc5189",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 720,
"y": 1060,
"wires": []
},
{
"id": "2384ab8e6fc4f9c6",
"type": "debug",
"z": "9b03cc7ebfdc5189",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 900,
"y": 760,
"wires": []
},
{
"id": "f5edf549bac85543",
"type": "debug",
"z": "9b03cc7ebfdc5189",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1100,
"y": 1040,
"wires": []
},
{
"id": "fccf5c6f1fbdd6d4",
"type": "debug",
"z": "9b03cc7ebfdc5189",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1090,
"y": 780,
"wires": []
},
{
"id": "da6d3fe21d3b98b3",
"type": "change",
"z": "9b03cc7ebfdc5189",
"name": "",
"rules": [
{
"t": "set",
"p": "options",
"pt": "msg",
"to": "$.payload.\"Actual # of Employees On Packing Line\"",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 700,
"y": 960,
"wires": [
[
"a61798580ae3ef30",
"1c40ee1352c943b0"
]
]
},
{
"id": "d446c5f28a9e1060",
"type": "file in",
"z": "9b03cc7ebfdc5189",
"name": "config_line",
"filename": "/home/dev/secured/ShippingStandards.csv",
"format": "utf8",
"chunk": false,
"sendError": false,
"encoding": "none",
"allProps": false,
"x": 410,
"y": 1340,
"wires": [
[
"e052bf4599d98ea3"
]
]
},
{
"id": "e052bf4599d98ea3",
"type": "csv",
"z": "9b03cc7ebfdc5189",
"name": "",
"sep": ",",
"hdrin": false,
"hdrout": "all",
"multi": "mult",
"ret": "\\n",
"temp": "",
"skip": "1",
"strings": true,
"include_empty_strings": false,
"include_null_values": false,
"x": 570,
"y": 1340,
"wires": [
[
"e477a853c1d11abf"
]
]
},
{
"id": "e477a853c1d11abf",
"type": "function",
"z": "9b03cc7ebfdc5189",
"name": "Create global array from CSV",
"func": "global.set(\"arrr\",msg.payload)\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 790,
"y": 1340,
"wires": [
[
"25e3a281a26feb12",
"988941d2fd75b6ac"
]
]
},
{
"id": "25e3a281a26feb12",
"type": "debug",
"z": "9b03cc7ebfdc5189",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 980,
"y": 1280,
"wires": []
},
{
"id": "907590c6a02af3f0",
"type": "debug",
"z": "9b03cc7ebfdc5189",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"x": 1160,
"y": 1280,
"wires": []
},
{
"id": "988941d2fd75b6ac",
"type": "function",
"z": "9b03cc7ebfdc5189",
"name": "Parse Line",
"func": "msg.payload = global.get(\"arrr[\"+flow.get(\"lineDisplay\")+\"].col4\")\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1030,
"y": 1340,
"wires": [
[
"907590c6a02af3f0",
"c2f961f96889b542"
]
]
},
{
"id": "c2f961f96889b542",
"type": "ui_text",
"z": "9b03cc7ebfdc5189",
"group": "1c2e0ff9fd3d33d8",
"order": 6,
"width": 0,
"height": 0,
"name": "",
"label": "Pots per Minute Actual Crew",
"format": "{{msg.payload}}",
"layout": "row-spread",
"className": "",
"x": 1250,
"y": 1340,
"wires": []
},
{
"id": "800d04b48c778463",
"type": "debug",
"z": "9b03cc7ebfdc5189",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 1500,
"y": 1040,
"wires": []
},
{
"id": "6d465fa8d382fc24",
"type": "debug",
"z": "9b03cc7ebfdc5189",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 1460,
"y": 880,
"wires": []
},
{
"id": "c3d5b3642f2fa419",
"type": "inject",
"z": "9b03cc7ebfdc5189",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"topic": "",
"payloadType": "date",
"x": 230,
"y": 1340,
"wires": [
[
"d446c5f28a9e1060"
]
]
},
{
"id": "1c2e0ff9fd3d33d8",
"type": "ui_group",
"name": "Stand",
"tab": "8c85a1ca378342da",
"order": 1,
"disp": true,
"width": "10",
"collapse": false,
"className": ""
},
{
"id": "8c85a1ca378342da",
"type": "ui_tab",
"name": "Read Standard test",
"icon": "dashboard",
"order": 16,
"disabled": false,
"hidden": false
}
]
ShippingStandards.txt (3.7 KB)