Read data from different payloads

Ok, I am a beginner and was just wondering that if i have 3 different injects(day,month year) and want to make a function to take these data from all these different payloads and when all 3 are clicked give output ad a complete date(dd/mm/yyyy). So is this even possible? And if yes please do help.

1 Like

Yes, it is possible but it isn't really the "Node-RED way".

To do it, you need to save all 3 inputs to flow or global variables then you can use a function node or a change node (using JSONata) to join them together.

You might want to ask yourself however, why use 3 injects that force you to join stuff together when you could have 1 inject with all 3 pieces of information together?

1 Like

Thanks for the help. Is there any resource where I can learn how to use node red perfectly? I am very much beginner and want to learn it perfectly.

Here another alternative to the first solution.

r-01

The join node will create an object with the three input (and every time an input is entered). The template node will create a string from the object.

[{"id":"be0fcc2e.ef7c8","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"5f1a0900.abc798","type":"inject","z":"be0fcc2e.ef7c8","name":"","topic":"day","payload":"DD","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":140,"wires":[["7f8bf4df.da9fac"]]},{"id":"a243ee87.0a727","type":"inject","z":"be0fcc2e.ef7c8","name":"","topic":"month","payload":"MM","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":180,"wires":[["7f8bf4df.da9fac"]]},{"id":"3ae58f90.3d478","type":"inject","z":"be0fcc2e.ef7c8","name":"","topic":"year","payload":"YY","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":220,"wires":[["7f8bf4df.da9fac"]]},{"id":"7f8bf4df.da9fac","type":"join","z":"be0fcc2e.ef7c8","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"3","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":330,"y":180,"wires":[["c24145ec.a8aab8"]]},{"id":"84855f1a.3180f","type":"debug","z":"be0fcc2e.ef7c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":610,"y":180,"wires":[]},{"id":"c24145ec.a8aab8","type":"template","z":"be0fcc2e.ef7c8","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload.day}}/{{payload.month}}/{{payload.year}}","output":"str","x":460,"y":180,"wires":[["84855f1a.3180f"]]}]
1 Like