Hi to all,
I have some problem with the node red context var.
I am trying to develope a function that send continuosly the msg.payload (that arrive from a form table) only when a context flow var became equals to 10.
The problem is that now I receive the form content (that is my msg.payload that should be sent continuosly) only when the context.var is equals to 10 and only when I press the "Send" button in the Form UI.
My goal is this :
- Write (ex.) "ABCD" in the Form Textbox
- Press Send in the Form UI
- If an external context.var is equal to 10 send continuosly the form textbox read ("ABCD")
- If the external context.vat is not equal to 10 don't send nothing.
I hope to have explained my problem as clearly as possible.
Thanks in advance to everybody!
I paste here my flow and some image of the function that I have written up to now.
[{"id":"5f3f2677.c5a0d8","type":"tab","label":"Flow 10","disabled":false,"info":""},{"id":"36d903a5.8fbc0c","type":"change","z":"5f3f2677.c5a0d8","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"test","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":390,"y":260,"wires":[["85ed380.215dfc8"]]},{"id":"81135576.81e3f8","type":"inject","z":"5f3f2677.c5a0d8","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"10","payloadType":"num","x":190,"y":220,"wires":[["36d903a5.8fbc0c"]]},{"id":"85ed380.215dfc8","type":"function","z":"5f3f2677.c5a0d8","name":"","func":"context.set('txt',msg.test);\ny = context.get('txt');\n//var y = context.get('txt');\nflow.set(\"testcode\",y);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"/*var x = msg.token;\nvar y = msg.test;\n\nflow.set(\"tokencode\",x);\nflow.set(\"testcode\",y);\nreturn msg;*/","x":600,"y":260,"wires":[[]]},{"id":"2ddf7711.e639a8","type":"inject","z":"5f3f2677.c5a0d8","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"150","payloadType":"num","x":190,"y":280,"wires":[["36d903a5.8fbc0c"]]},{"id":"9d889dde.f0264","type":"ui_form","z":"5f3f2677.c5a0d8","name":"","label":"DataTable","group":"a9584ee2.24eac","order":1,"width":"5","height":"9","options":[{"label":"Baia Inizio","value":"StartBay","type":"text","required":false,"rows":null},{"label":"Baia 2","value":"Bay_2","type":"text","required":false,"rows":null},{"label":"Baia 3","value":"Bay_3","type":"text","required":false,"rows":null},{"label":"Baia 4","value":"Bay_4","type":"text","required":false,"rows":null},{"label":"Baia 5","value":"Bay_5","type":"text","required":false,"rows":null},{"label":"Baia 6","value":"Bay_6","type":"text","required":false,"rows":null},{"label":"Baia 7","value":"Bay_7","type":"text","required":false,"rows":null},{"label":"Baia 8","value":"Bay_8","type":"text","required":false,"rows":null},{"label":"Baia 9","value":"Bay_9","type":"text","required":false,"rows":null},{"label":"Baia Fine","value":"EndBay","type":"text","required":false,"rows":null}],"formValue":{"StartBay":"","Bay_2":"","Bay_3":"","Bay_4":"","Bay_5":"","Bay_6":"","Bay_7":"","Bay_8":"","Bay_9":"","EndBay":""},"payload":"","submit":"invio","cancel":"cancel","topic":"","x":180,"y":380,"wires":[["1f22c1bc.85b76e"]]},{"id":"d277370f.ea58c8","type":"debug","z":"5f3f2677.c5a0d8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":630,"y":380,"wires":[]},{"id":"1f22c1bc.85b76e","type":"function","z":"5f3f2677.c5a0d8","name":"","func":"context.set('start',msg.payload.StartBay);\n//var StartBay = context.get('start');\nStartBay = context.get('start');\ntestcode1 = flow.get(\"testcode\");\nif (testcode1 == 10){\n //return {payload:StartBay};\n node.send({payload:StartBay});\n}\nelse {\nreturn null;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":400,"y":380,"wires":[["d277370f.ea58c8"]]},{"id":"a9584ee2.24eac","type":"ui_group","name":"Rulliere","tab":"a4cbd78a.6d5d68","order":1,"disp":true,"width":"20","collapse":false},{"id":"a4cbd78a.6d5d68","type":"ui_tab","name":"Cantiere","icon":"dashboard","disabled":false,"hidden":false}]