Hello Forum
I have a project and for that I need to transfer one flow into a subflow. The problem is that the Subflow doesn't behave like the flow. I just transfered it into a subflow and changed the global variable names.
Here I have my flow:
[{"id":"b3a350a4.90b4c","type":"subflow","name":"Subflow 1","info":"","category":"","in":[],"out":[{"x":960,"y":360,"wires":[{"id":"3fdb35fd.8f07aa","port":0}]},{"x":960,"y":20,"wires":[{"id":"57997b6b.0e5994","port":0}]},{"x":1080,"y":180,"wires":[{"id":"67b1be0.df80a44","port":0}]},{"x":660,"y":340,"wires":[]}],"env":[{"name":"Group","type":"str","value":"Office"}],"color":"#DDAA99"},{"id":"67b1be0.df80a44","type":"ui_table","z":"b3a350a4.90b4c","group":"5757624b.54259c","name":"","order":0,"width":"10","height":"16","columns":[],"outputs":1,"cts":true,"x":870,"y":160,"wires":[["57997b6b.0e5994","7b46fa49.e60904","3fdb35fd.8f07aa"]]},{"id":"32dee164.3b4b1e","type":"inject","z":"b3a350a4.90b4c","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":"0.6","topic":"","payload":"true","payloadType":"bool","x":390,"y":140,"wires":[["43f5bd69.62b2a4"]]},{"id":"43f5bd69.62b2a4","type":"function","z":"b3a350a4.90b4c","name":"","func":"global.set(env.get(\"Group\") + \"ID\", 9);\nmsg.payload = [\n {\n \"woche\": \"Montag\",\n \"status\": 0,\n \"_children\": [\n {\n \"id\": 8,\n \"end\": \"22:00\",\n \"rawend\": 1320,\n \"temp\": 23,\n \"add\": 0,\n \"delete\": 0\n },\n {\n \"id\": 1,\n \"end\": \"24:00\",\n \"rawend\": 1440,\n \"temp\": 25,\n \"add\": 0,\n \"delete\": 0\n }\n ]\n },\n {\n \"woche\": \"Dienstag\",\n \"status\": 0,\n \"vortag\": 1,\n \"_children\": [\n {\n \"id\": 2,\n \"end\": \"24:00\",\n \"rawend\": 1440,\n \"temp\": 21,\n \"add\": 0,\n \"delete\": 0\n }\n ]\n },\n {\n \"woche\": \"Mittwoch\",\n \"start\": \"\",\n \"status\": 0,\n \"vortag\": 1,\n \"_children\": [\n {\n \"id\": 3,\n \"end\": \"24:00\",\n \"rawend\": 1440,\n \"temp\": 21,\n \"add\": 0,\n \"delete\": 0\n }\n ]\n },\n {\n \"woche\": \"Donnerstag\",\n \"status\": 0,\n \"vortag\": 1,\n \"_children\": [\n {\n \"id\": 4,\n \"end\": \"24:00\",\n \"rawend\": 1440,\n \"temp\": 21,\n \"add\": 0,\n \"delete\": 0\n }\n ]\n },\n {\n \"woche\": \"Freitag\",\n \"start\": \"\",\n \"status\": 0,\n \"vortag\": 1,\n \"_children\": [\n {\n \"id\": 5,\n \"end\": \"24:00\",\n \"rawend\": 1440,\n \"temp\": 21,\n \"add\": 0,\n \"delete\": 0\n }\n ]\n },\n {\n \"woche\": \"Samstag\",\n \"start\": \"\",\n \"status\": 0,\n \"vortag\": 1,\n \"_children\": [\n {\n \"id\": 6,\n \"end\": \"24:00\",\n \"rawend\": 1440,\n \"temp\": 21,\n \"add\": 0,\n \"delete\": 0\n }\n ]\n },\n {\n \"woche\": \"Sonntag\",\n \"start\": \"\",\n \"status\": 0,\n \"vortag\": 1,\n \"_children\": [\n {\n \"id\": 7,\n \"end\": \"24:00\",\n \"rawend\": 1440,\n \"temp\": 21,\n \"add\": 0,\n \"delete\": 0\n }\n ]\n }\n];\nglobal.set(env.get(\"Group\"), msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":540,"y":140,"wires":[["67b1be0.df80a44"]]},{"id":"56eb05d7.db0dac","type":"change","z":"b3a350a4.90b4c","name":"BACKUP","rules":[{"t":"set","p":"ui_control","pt":"msg","to":"{\"tabulator\":{\"dataTree\":true,\"dataTreeStartExpanded\":true,\"headerSort\":false,\"columns\":[{\"title\":\"ID\",\"field\":\"id\",\"width\":50,\"visible\":false,\"editor\":false},{\"title\":\"Woche\",\"field\":\"woche\",\"width\":100,\"responsive\":0},{\"title\":\"Bis\",\"field\":\"end\",\"width\":75,\"validator\":[\"regex:^([0-1][0-9]|2[0-3]).[0-5][0,5]$\"],\"cellEdited\":\"function(cell){this.send({topic:\\\"editEnd\\\",payload:cell.getData(),ui_control:{callback:\\\"it worked\\\"}})}\",\"editor\":\"input\"},{\"title\":\"Temp\",\"field\":\"temp\",\"width\":75,\"validator\":[\"required\",\"min:5\",\"max:30\",\"numeric\"],\"cellEdited\":\"function(cell){this.send({topic:\\\"editTemp\\\",payload:cell.getData(),ui_control:{callback:\\\"it worked\\\"}})}\",\"editor\":\"input\"},{\"title\":\"wie Vortag\",\"field\":\"vortag\",\"formatter\":\"function(cell, formatterParams, onRendered){var html=\\\"<i class=\\\\\\\"\\\";switch(cell.getValue()) {case 0: html+=\\\"fa fa-toggle-off fa-2x\\\\\\\" style=\\\\\\\"color:red\\\\\\\"\\\"; break;case 1: html+=\\\"fa fa-toggle-on fa-2x\\\\\\\" style=\\\\\\\"color:green\\\\\\\"\\\"; break;}html+='\\\\\\\"></i>';return html; }\",\"width\":100},{\"field\":\"add\",\"width\":50,\"formatter\":\"function(cell, formatterParams, onRendered){var html=\\\"<i class=\\\\\\\"\\\";switch(cell.getValue()) {case 0: html+=\\\"fa fa-plus-circle fa-2x\\\\\\\" style=\\\\\\\"color:green\\\\\\\"\\\"; break;}html+='\\\\\\\"></i>';return html; }\"},{\"field\":\"delete\",\"width\":55,\"formatter\":\"function(cell, formatterParams, onRendered){var html=\\\"<i class=\\\\\\\"\\\";switch(cell.getValue()) {case 0: html+=\\\"fa fa-minus-circle fa-2x\\\\\\\" style=\\\\\\\"color:red\\\\\\\"\\\"; break;}html+='\\\\\\\"></i>';return html; }\"}]}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":200,"wires":[["67b1be0.df80a44"]]},{"id":"7e53f1c4.c3507","type":"inject","z":"b3a350a4.90b4c","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":390,"y":200,"wires":[["56eb05d7.db0dac"]]},{"id":"3c04f077.5977b","type":"ui_button","z":"b3a350a4.90b4c","name":"","group":"5757624b.54259c","order":1,"width":0,"height":0,"passthru":false,"label":"Reset","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":350,"y":80,"wires":[["43f5bd69.62b2a4"]]},{"id":"7b46fa49.e60904","type":"function","z":"b3a350a4.90b4c","name":"edit Filter","func":"if (msg.topic == \"end\" && msg.payload.id < 8){\n msg.payload = global.get(env.get(\"Group\"));\n return [null, msg];\n }\n\nif (msg.topic == \"editTemp\" || msg.topic == \"editEnd\"){\n global.get(env.get(\"Group\")).forEach(function(element){\n element._children.forEach(function(child){\n if (child.id == msg.payload.id){\n child.end = msg.payload.end;\n child.temp = msg.payload.temp;\n child.rawend = parseInt(msg.payload.end.slice(0, 2)) * 60 + parseInt(msg.payload.end.slice(3));\n } else {\n child.rawend = parseInt(child.end.slice(0, 2)) * 60 + parseInt(child.end.slice(3));\n }\n }) \n });\n return [msg, null];\n} else {\n return;\n}","outputs":2,"noerr":0,"initialize":"","finalize":"","x":1100,"y":260,"wires":[[],["67b1be0.df80a44"]]},{"id":"57997b6b.0e5994","type":"function","z":"b3a350a4.90b4c","name":"Vortag switch","func":"var arr = [];\nif (msg.topic == \"vortag\" && msg.row > 0) {\n if (msg.payload.vortag == 0) {\n msg.payload.vortag = 1;\n } else {\n msg.payload.vortag = 0;\n }\n global.get(env.get(\"Group\")).forEach(function(element) {\n if (element.woche == msg.payload.woche) {\n arr.push(msg.payload);\n } else {\n arr.push(element);\n }\n });\n msg.payload = arr;\n global.set(env.get(\"Group\"), arr);\n return msg;\n} else {\n return;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":820,"y":60,"wires":[["67b1be0.df80a44"]]},{"id":"3fdb35fd.8f07aa","type":"function","z":"b3a350a4.90b4c","name":"add row","func":"var Id = global.get(env.get(\"Group\") + \"ID\");\nvar index = 0;\nif (msg.topic == \"add\" || msg.topic == \"delete\") {\n for (var element of global.get(env.get(\"Group\"))) {\n for (var child of element._children) {\n if (child.id === msg.payload.id) {\n if (msg.topic == \"add\") {\n if (element._children.length > 12) {\n return;\n } else {\n ++Id;\n index = element._children.indexOf(child);\n element._children.splice(index, 0, {\n \"id\": Id,\n \"end\": \"\",\n \"temp\": \"\",\n \"add\": 0,\n \"delete\": 0\n });\n global.set(env.get(\"Group\") + \"ID\", Id);\n msg.payload = global.get(env.get(\"Group\"));\n return msg;\n }\n } else {\n if (element._children.length < 2 || child.end == \"24:00\") {\n return;\n } else {\n index = element._children.indexOf(child);\n element._children.splice(index, 1);\n msg.payload = global.get(env.get(\"Group\"));\n return msg;\n }\n }\n }\n }\n }\n} else {\n return;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":820,"y":400,"wires":[["67b1be0.df80a44"]]},{"id":"5757624b.54259c","type":"ui_group","name":"Wochenplan","tab":"f5085d6d.61f9a","order":1,"disp":true,"width":"10","collapse":false},{"id":"f5085d6d.61f9a","type":"ui_tab","name":"Wochenplan","icon":"dashboard","order":7,"disabled":false,"hidden":false},{"id":"d3ccd033.15912","type":"subflow:b3a350a4.90b4c","z":"f6f2187d.f17ca8","name":"","env":[],"x":1460,"y":760,"wires":[["c61fa740.907eb8"],["bf412f38.7255b"],["6d425fcb.35fc2"],["cc0d4571.e67208"]]},{"id":"65062fd6.32099","type":"ui_table","z":"f6f2187d.f17ca8","group":"5757624b.54259c","name":"","order":0,"width":"10","height":"16","columns":[],"outputs":1,"cts":true,"x":1090,"y":720,"wires":[["d779d42f.309c88","eae73fac.b3581","45dd7834.2685d8","2daa6cad.142614"]]},{"id":"45dd7834.2685d8","type":"debug","z":"f6f2187d.f17ca8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1290,"y":680,"wires":[]},{"id":"d59385b.f7a6478","type":"inject","z":"f6f2187d.f17ca8","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":"0.6","topic":"","payload":"true","payloadType":"bool","x":610,"y":700,"wires":[["cda4870a.7421b8"]]},{"id":"cda4870a.7421b8","type":"function","z":"f6f2187d.f17ca8","name":"","func":"global.set(\"WochenplanID\", 9);\nmsg.payload = [\n {\n \"woche\": \"Montag\",\n \"status\": 0,\n \"_children\": [\n {\n \"id\": 8,\n \"end\": \"22:00\",\n \"rawend\": 1320,\n \"temp\": 23,\n \"add\": 0,\n \"delete\": 0\n },\n {\n \"id\": 1,\n \"end\": \"24:00\",\n \"rawend\": 1440,\n \"temp\": 25,\n \"add\": 0,\n \"delete\": 0\n }\n ]\n },\n {\n \"woche\": \"Dienstag\",\n \"status\": 0,\n \"vortag\": 1,\n \"_children\": [\n {\n \"id\": 2,\n \"end\": \"24:00\",\n \"rawend\": 1440,\n \"temp\": 21,\n \"add\": 0,\n \"delete\": 0\n }\n ]\n },\n {\n \"woche\": \"Mittwoch\",\n \"start\": \"\",\n \"status\": 0,\n \"vortag\": 1,\n \"_children\": [\n {\n \"id\": 3,\n \"end\": \"24:00\",\n \"rawend\": 1440,\n \"temp\": 21,\n \"add\": 0,\n \"delete\": 0\n }\n ]\n },\n {\n \"woche\": \"Donnerstag\",\n \"status\": 0,\n \"vortag\": 1,\n \"_children\": [\n {\n \"id\": 4,\n \"end\": \"24:00\",\n \"rawend\": 1440,\n \"temp\": 21,\n \"add\": 0,\n \"delete\": 0\n }\n ]\n },\n {\n \"woche\": \"Freitag\",\n \"start\": \"\",\n \"status\": 0,\n \"vortag\": 1,\n \"_children\": [\n {\n \"id\": 5,\n \"end\": \"24:00\",\n \"rawend\": 1440,\n \"temp\": 21,\n \"add\": 0,\n \"delete\": 0\n }\n ]\n },\n {\n \"woche\": \"Samstag\",\n \"start\": \"\",\n \"status\": 0,\n \"vortag\": 1,\n \"_children\": [\n {\n \"id\": 6,\n \"end\": \"24:00\",\n \"rawend\": 1440,\n \"temp\": 21,\n \"add\": 0,\n \"delete\": 0\n }\n ]\n },\n {\n \"woche\": \"Sonntag\",\n \"start\": \"\",\n \"status\": 0,\n \"vortag\": 1,\n \"_children\": [\n {\n \"id\": 7,\n \"end\": \"24:00\",\n \"rawend\": 1440,\n \"temp\": 21,\n \"add\": 0,\n \"delete\": 0\n }\n ]\n }\n];\nglobal.set(\"table\", msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":760,"y":700,"wires":[["65062fd6.32099"]]},{"id":"d779d42f.309c88","type":"function","z":"f6f2187d.f17ca8","name":"add row & vortag","func":"var Id = global.get(\"WochenplanID\");\nvar index = 0;\nvar element = \"\";\nvar child = \"\";\nif (msg.topic == \"add\" || msg.topic == \"delete\") {\n for (element of global.get(\"table\")) {\n for (child of element._children) {\n if (child.id === msg.payload.id) {\n if (msg.topic == \"add\") {\n if (element._children.length > 12) {\n return;\n } else {\n ++Id;\n index = element._children.indexOf(child);\n element._children.splice(index, 0, {\n \"id\": Id,\n \"end\": \"\",\n \"temp\": \"\",\n \"add\": 0,\n \"delete\": 0\n });\n global.set(\"WochenplanID\", Id);\n msg.payload = global.get(\"table\");\n return msg;\n }\n } else {\n if (element._children.length < 2 || child.end == \"24:00\") {\n return;\n } else {\n index = element._children.indexOf(child);\n element._children.splice(index, 1);\n msg.payload = global.get(\"table\");\n return msg;\n }\n }\n }\n }\n }\n} else {\n return;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1010,"y":860,"wires":[["33c0e8f2.e3aca8","65062fd6.32099"]]},{"id":"a8619365.d138a","type":"change","z":"f6f2187d.f17ca8","name":"BACKUP","rules":[{"t":"set","p":"ui_control","pt":"msg","to":"{\"tabulator\":{\"dataTree\":true,\"dataTreeStartExpanded\":true,\"headerSort\":false,\"columns\":[{\"title\":\"ID\",\"field\":\"id\",\"width\":50,\"visible\":false,\"editor\":false},{\"title\":\"Woche\",\"field\":\"woche\",\"width\":100,\"responsive\":0},{\"title\":\"Bis\",\"field\":\"end\",\"width\":75,\"validator\":[\"regex:^([0-1][0-9]|2[0-3]).[0-5][0,5]$\"],\"cellEdited\":\"function(cell){this.send({topic:\\\"editEnd\\\",payload:cell.getData(),ui_control:{callback:\\\"it worked\\\"}})}\",\"editor\":\"input\"},{\"title\":\"Temp\",\"field\":\"temp\",\"width\":75,\"validator\":[\"required\",\"min:5\",\"max:30\",\"numeric\"],\"cellEdited\":\"function(cell){this.send({topic:\\\"editTemp\\\",payload:cell.getData(),ui_control:{callback:\\\"it worked\\\"}})}\",\"editor\":\"input\"},{\"title\":\"wie Vortag\",\"field\":\"vortag\",\"formatter\":\"function(cell, formatterParams, onRendered){var html=\\\"<i class=\\\\\\\"\\\";switch(cell.getValue()) {case 0: html+=\\\"fa fa-toggle-off fa-2x\\\\\\\" style=\\\\\\\"color:red\\\\\\\"\\\"; break;case 1: html+=\\\"fa fa-toggle-on fa-2x\\\\\\\" style=\\\\\\\"color:green\\\\\\\"\\\"; break;}html+='\\\\\\\"></i>';return html; }\",\"width\":100},{\"field\":\"add\",\"width\":50,\"formatter\":\"function(cell, formatterParams, onRendered){var html=\\\"<i class=\\\\\\\"\\\";switch(cell.getValue()) {case 0: html+=\\\"fa fa-plus-circle fa-2x\\\\\\\" style=\\\\\\\"color:green\\\\\\\"\\\"; break;}html+='\\\\\\\"></i>';return html; }\"},{\"field\":\"delete\",\"width\":55,\"formatter\":\"function(cell, formatterParams, onRendered){var html=\\\"<i class=\\\\\\\"\\\";switch(cell.getValue()) {case 0: html+=\\\"fa fa-minus-circle fa-2x\\\\\\\" style=\\\\\\\"color:red\\\\\\\"\\\"; break;}html+='\\\\\\\"></i>';return html; }\"}]}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":760,"wires":[["65062fd6.32099"]]},{"id":"a193b7bd.760ae8","type":"inject","z":"f6f2187d.f17ca8","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":610,"y":760,"wires":[["a8619365.d138a"]]},{"id":"520c95c0.53d90c","type":"ui_button","z":"f6f2187d.f17ca8","name":"","group":"5757624b.54259c","order":1,"width":0,"height":0,"passthru":false,"label":"ResettTable","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":590,"y":640,"wires":[["cda4870a.7421b8"]]},{"id":"eae73fac.b3581","type":"function","z":"f6f2187d.f17ca8","name":"edit Filter","func":"if (msg.topic == \"end\" && msg.payload.id < 8){\n msg.payload = global.get(\"table\");\n return [null, msg];\n }\n\nif (msg.topic == \"editTemp\" || msg.topic == \"editEnd\"){\n global.get(\"table\").forEach(function(element){\n element._children.forEach(function(child){\n if (child.id == msg.payload.id){\n child.end = msg.payload.end;\n child.temp = msg.payload.temp;\n child.rawend = parseInt(msg.payload.end.slice(0, 2)) * 60 + parseInt(msg.payload.end.slice(3));\n } else {\n child.rawend = parseInt(child.end.slice(0, 2)) * 60 + parseInt(child.end.slice(3));\n }\n }) \n });\n return [msg, null];\n} else {\n return;\n}","outputs":2,"noerr":0,"initialize":"","finalize":"","x":1260,"y":840,"wires":[[],["65062fd6.32099"]]},{"id":"c61fa740.907eb8","type":"debug","z":"f6f2187d.f17ca8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1610,"y":700,"wires":[]},{"id":"2daa6cad.142614","type":"function","z":"f6f2187d.f17ca8","name":"","func":"var arr = [];\nif (msg.topic == \"vortag\" && msg.row > 0) {\n if (msg.payload.vortag == 0) {\n msg.payload.vortag = 1;\n } else {\n msg.payload.vortag = 0;\n }\n global.get(\"table\").forEach(function(element) {\n if (element.woche == msg.payload.woche) {\n arr.push(msg.payload);\n } else {\n arr.push(element);\n }\n });\n msg.payload = arr;\n global.set(\"table\", arr);\n return msg;\n} else {\n return;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1000,"y":600,"wires":[["d79041f.dcf30c","65062fd6.32099"]]},{"id":"d79041f.dcf30c","type":"debug","z":"f6f2187d.f17ca8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1170,"y":600,"wires":[]},{"id":"33c0e8f2.e3aca8","type":"debug","z":"f6f2187d.f17ca8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1250,"y":900,"wires":[]},{"id":"bf412f38.7255b","type":"debug","z":"f6f2187d.f17ca8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1650,"y":740,"wires":[]},{"id":"6d425fcb.35fc2","type":"debug","z":"f6f2187d.f17ca8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1650,"y":780,"wires":[]},{"id":"cc0d4571.e67208","type":"debug","z":"f6f2187d.f17ca8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1610,"y":820,"wires":[]}]
It displays a table where I can add and delete rows. The table works fine in the Flow but in the subflow it doesn't display the updates. The output is the same. The table just don't want to display the new row.
Can somebody help?