Using a form to add a tag to javascript object before saving to influxDB

Hi,

I have a flow which generate a javascript object which is
data = {x: Math.random(), y: Math.random());

Data is generated every 2 seconds using timestamp node.

Then i have user a form, to get the id (name) of the user, when then user enter is name, I'd like my objet to be :
data = {x: Math.random(), y: Math.random(), id: name);

I am able to get that, but only once, when the user click to "submit", or I'd like that when the user click on "submit" his name stay on the object at every iteration, so when I will save my javascript object inside influx DB I have for each timestamp the name of the person as a tag for my x and y value.

Here is my flow

[{"id":"8045bb84.1d25e8","type":"tab","label":"Flow 4","disabled":false,"info":""},{"id":"960f0264.2ab98","type":"inject","z":"8045bb84.1d25e8","name":"","topic":"","payload":"","payloadType":"date","repeat":"2","crontab":"","once":false,"onceDelay":0.1,"x":390,"y":260,"wires":[["98a9fb1e.2de9f8"]]},{"id":"98a9fb1e.2de9f8","type":"function","z":"8045bb84.1d25e8","name":"","func":"msg.payload = {\n x: Math.random(),\n y: Math.random()\n};\nmsg.topic = 'data';\nreturn msg;","outputs":1,"noerr":0,"x":570,"y":260,"wires":[["d506dda2.a545b"]]},{"id":"d506dda2.a545b","type":"join","z":"8045bb84.1d25e8","name":"","mode":"custom","build":"merged","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":770,"y":260,"wires":[["676c767c.91c2c8"]]},{"id":"676c767c.91c2c8","type":"debug","z":"8045bb84.1d25e8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":910,"y":400,"wires":[]},{"id":"ec0e6a9.8400298","type":"ui_form","z":"8045bb84.1d25e8","name":"","label":"","group":"cac40ce3.5e7db","order":0,"width":0,"height":0,"options":[{"label":"","value":"","type":"text","required":true,"rows":null}],"formValue":{"":""},"payload":"","submit":"submit","cancel":"cancel","topic":"id","x":290,"y":360,"wires":[["e751df97.df2f1"]]},{"id":"e751df97.df2f1","type":"function","z":"8045bb84.1d25e8","name":"","func":"msg.payload = Object.values(msg.payload);\nmsg.payload = {\n id: msg.payload[0],\n};\n\n\nreturn msg;","outputs":1,"noerr":0,"x":490,"y":360,"wires":[["d506dda2.a545b"]]},{"id":"cac40ce3.5e7db","type":"ui_group","z":"","name":"Temps","tab":"55228fe4.4bfeb","order":2,"disp":true,"width":"6","collapse":false},{"id":"55228fe4.4bfeb","type":"ui_tab","z":"","name":"Ecran principal","icon":"home","order":1,"disabled":false,"hidden":false}]

Unfortunately your flow is not importable.
Have a look at this post to see how to share a flow, then edit your previous post and we will be able to have a look.
If I were doing this I would look at using a Join node in key/value pair or merge mode to combine the contents from the data stream and the form.

Ok thank you, I updated my post

You have specified that is it to expect 2 message parts and have not checked 'and every subsequent message'. That means that it needs a message on each path before it will send on a message. If you select the every subsequent message box then you will get a message sent each time any message is received (after the first two). Hopefully that will do what you want.

1 Like

Thank it works