Newbie storing msg.payload

Hello All.
newbie here, trying to understand nodered.

I have a msg.payload that I need to save for later use.
Meanwhile I need to perform some processess that change the msg.payload.
After them I need to recover again the first msg.payload to mix some values from first msg.payload and last msg.payload.
I am unable to figure out how to do this.
I tried to store in variable, do a context.set and a context.get but nothing work for me.

Do you have some suggestions on how to do this?
Thank you in advance and best regards.

Check the documentation: working with context.
In the context section read about "Using content in a flow".

1 Like

Very fast and this is the trick
Thank you

If you only need to save it so that you can use it later down the flow then you can copy it to a different attribute of the message. Most nodes will not (and generally should not) change attributes that they don't use, so the value should still be there when you need it later on. So in your case you could use a Change node to Set msg.payloadSaved to msg.payload, then later on down the flow when you want to use it then it should still be there in msg.payloadSaved for you to extract the data you need.

4 Likes

Good option too.
thank you

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