Change msg.payload to msg.payload.ANYNAME

Hello,

I'm new on node red and well, messages are quite hard for me to understand... I tried https://nodered.org/docs/user-guide/messages but I can't get my issue resolved...

HOW can I pass a number within msg.payload on to a different message e.g. msg.payload.xyz? Could not do it with set to msg.payload.xyz .....

I am trying to send data to a google form, that will send it to a google spreadsheet. To do so, I need to send a message that contains a number (measurement value) with the name msg.payload.xyz

Thanks!
toby

Welcome to the forum. Have a look at the change node!

I had already tried that within the change node without success...

Look thru this

So 1st step is to save the old msg.payload somewhere
Then delete it
Then set msg.payload.xyz to the old payload
Then to tidy up - (but not necessary) delete our temp copy of the payload

The basic issue is that msg.payload can be swapped/set to numbers/strings at will but you can't then change to using it as an object to hold other objects/values.

It has to be deleted and then re-created as an object

Prob not strickly using the correct terms here but this is the way I got my head around the issue :slight_smile:

or use the move option instead.... which does the save/delete/replace for you.

1 Like

That was going to be lesson 2 once the OP has got their head around the concept :slight_smile:

Thanks a lot!! this solved my issue! :smiley: :smiley:
Also tried it with move but did not work out straight away. Will try it again later but as for now, I leave it like that - never change a working system or so :smiley:
toby

It should work and its a lot more compact

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