Setting config node attribs from flow

Good morning everyone,

I'm trying to use environmental variables to set variables in nodes included in a subflow.
This works fine for the following flow:

[{"id":"7abc9241.f6146c","type":"subflow","name":"CSV to table","info":"","category":"","in":[{"x":40,"y":80,"wires":[{"id":"9908ee13.fa3d3"}]}],"out":[{"x":900,"y":200,"wires":[{"id":"ddbbe8a2.c22088","port":0}]}],"env":[{"name":"path","type":"str","value":""}],"color":"#DDAA99"},{"id":"8e7ec719.896d98","type":"csv","z":"7abc9241.f6146c","name":"","sep":";","hdrin":true,"hdrout":"none","multi":"one","ret":"\\r\\n","temp":"","skip":"0","strings":true,"include_empty_strings":"","include_null_values":false,"x":410,"y":200,"wires":[["ddbbe8a2.c22088"]]},{"id":"e5190647.5bb0e8","type":"file in","z":"7abc9241.f6146c","name":"","filename":"Temp.csv","format":"utf8","chunk":false,"sendError":false,"encoding":"none","x":250,"y":200,"wires":[["8e7ec719.896d98"]]},{"id":"9b1d865d.624808","type":"change","z":"7abc9241.f6146c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":80,"wires":[["e5190647.5bb0e8"]]},{"id":"ddbbe8a2.c22088","type":"join","z":"7abc9241.f6146c","name":"","mode":"auto","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":570,"y":200,"wires":[[]]},{"id":"9908ee13.fa3d3","type":"ftp in","z":"7abc9241.f6146c","ftp":"177593fc.d1c26c","operation":"get","filename":"${path}","localFilename":"Temp.csv","name":"GET1","x":450,"y":80,"wires":[["9b1d865d.624808"]]},{"id":"177593fc.d1c26c","type":"ftp","host":"192.168.1.105","port":"","secureOptions":"","user":"admin","connTimeout":"","pasvTimeout":"","keepalive":""},{"id":"4b6057.d5783fa8","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"2239f04e.f343c","type":"subflow:7abc9241.f6146c","z":"4b6057.d5783fa8","name":"","env":[{"name":"path","value":"CSV/Production.csv","type":"str"},{"name":"host","value":"192.168.1.105","type":"str"},{"name":"filename","value":"Production.csv","type":"str"},{"name":"filename1","value":"Production.csv","type":"str"},{"name":"ftp-username","value":"admin","type":"str"},{"name":"ftp-password","value":"admin","type":"str"},{"name":"ftp","value":"test","type":"str"},{"name":"ftp-host","value":"192.168.1.105","type":"str"}],"x":750,"y":240,"wires":[["83ca2c05.42fbf"]]},{"id":"173d1ae6.c077f5","type":"ui_table","z":"4b6057.d5783fa8","group":"39801be7.3a5e64","name":"","order":0,"width":"16","height":"5","columns":[],"outputs":0,"cts":false,"x":1110,"y":240,"wires":[]},{"id":"83ca2c05.42fbf","type":"function","z":"4b6057.d5783fa8","name":"","func":"msg.ui_control =\n\n{\n    \"tabulator\": {\n        \"resizableColumns\": false,\n        \"movableColumns\": false,\n        \"selectable\": false,\n        \"Height\": 500,\n        \"layout\":\"fitData\",\n    },\n    \"customHeight\": 120\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":940,"y":240,"wires":[["173d1ae6.c077f5","413d2e31.d68c6"]]},{"id":"7d318bd4.dbbfa4","type":"inject","z":"4b6057.d5783fa8","name":"","props":[],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","x":550,"y":240,"wires":[["2239f04e.f343c"]]},{"id":"413d2e31.d68c6","type":"debug","z":"4b6057.d5783fa8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1130,"y":180,"wires":[]},{"id":"39801be7.3a5e64","type":"ui_group","name":"Default","tab":"7a01a3c0.d5784c","order":1,"disp":true,"width":"20","collapse":false},{"id":"7a01a3c0.d5784c","type":"ui_tab","name":"Test","icon":"dashboard","disabled":false,"hidden":false}]

However, i want to use a similar environmental variable in the config section of a node too (in this case the Host, username and password in the FTP GET node). I have tried the following flow but it does not seem to work:

[{"id":"7abc9241.f6146c","type":"subflow","name":"CSV to table","info":"","category":"","in":[{"x":40,"y":80,"wires":[{"id":"9908ee13.fa3d3"},{"id":"bf90fb7e.c073c8"}]}],"out":[{"x":900,"y":200,"wires":[{"id":"ddbbe8a2.c22088","port":0}]}],"env":[{"name":"path","type":"str","value":""},{"name":"host","type":"str","value":""}],"color":"#DDAA99"},{"id":"8e7ec719.896d98","type":"csv","z":"7abc9241.f6146c","name":"","sep":";","hdrin":true,"hdrout":"none","multi":"one","ret":"\\r\\n","temp":"","skip":"0","strings":true,"include_empty_strings":"","include_null_values":false,"x":410,"y":200,"wires":[["ddbbe8a2.c22088"]]},{"id":"e5190647.5bb0e8","type":"file in","z":"7abc9241.f6146c","name":"","filename":"Temp.csv","format":"utf8","chunk":false,"sendError":false,"encoding":"none","x":250,"y":200,"wires":[["8e7ec719.896d98"]]},{"id":"9b1d865d.624808","type":"change","z":"7abc9241.f6146c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":80,"wires":[["e5190647.5bb0e8"]]},{"id":"ddbbe8a2.c22088","type":"join","z":"7abc9241.f6146c","name":"","mode":"auto","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":570,"y":200,"wires":[[]]},{"id":"9908ee13.fa3d3","type":"ftp in","z":"7abc9241.f6146c","ftp":"177593fc.d1c26c","operation":"get","filename":"${path}","localFilename":"Temp.csv","name":"GET1","x":450,"y":80,"wires":[["9b1d865d.624808"]]},{"id":"bf90fb7e.c073c8","type":"debug","z":"7abc9241.f6146c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":600,"y":40,"wires":[]},{"id":"177593fc.d1c26c","type":"ftp","host":"${host}","port":"","secureOptions":"","user":"admin","connTimeout":"","pasvTimeout":"","keepalive":""},{"id":"4b6057.d5783fa8","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"2239f04e.f343c","type":"subflow:7abc9241.f6146c","z":"4b6057.d5783fa8","name":"","env":[{"name":"path","value":"CSV/Production.csv","type":"str"},{"name":"host","value":"192.168.1.105","type":"str"},{"name":"filename","value":"Production.csv","type":"str"},{"name":"filename1","value":"Production.csv","type":"str"},{"name":"ftp-username","value":"admin","type":"str"},{"name":"ftp-password","value":"admin","type":"str"},{"name":"ftp","value":"test","type":"str"},{"name":"ftp-host","value":"192.168.1.105","type":"str"}],"x":750,"y":240,"wires":[["83ca2c05.42fbf"]]},{"id":"173d1ae6.c077f5","type":"ui_table","z":"4b6057.d5783fa8","group":"39801be7.3a5e64","name":"","order":0,"width":"16","height":"5","columns":[],"outputs":0,"cts":false,"x":1110,"y":240,"wires":[]},{"id":"83ca2c05.42fbf","type":"function","z":"4b6057.d5783fa8","name":"","func":"msg.ui_control =\n\n{\n    \"tabulator\": {\n        \"resizableColumns\": false,\n        \"movableColumns\": false,\n        \"selectable\": false,\n        \"Height\": 500,\n        \"layout\":\"fitData\",\n    },\n    \"customHeight\": 120\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":940,"y":240,"wires":[["173d1ae6.c077f5","413d2e31.d68c6"]]},{"id":"7d318bd4.dbbfa4","type":"inject","z":"4b6057.d5783fa8","name":"","props":[],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","x":550,"y":240,"wires":[["2239f04e.f343c"]]},{"id":"413d2e31.d68c6","type":"debug","z":"4b6057.d5783fa8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1130,"y":180,"wires":[]},{"id":"39801be7.3a5e64","type":"ui_group","name":"Default","tab":"7a01a3c0.d5784c","order":1,"disp":true,"width":"20","collapse":false},{"id":"7a01a3c0.d5784c","type":"ui_tab","name":"Test","icon":"dashboard","disabled":false,"hidden":false}]

This question is similar to this post i found on the old google group forum: https://groups.google.com/g/node-red/c/W5cN_3mUNVQ

However, this does not show how he solved it and I am wondering if anyone here knows how I can achieve what I am trying to do?

Best regards.

1 Like

A config-node picker in subflow properties might be a better solution for this. What do you think?

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