# Change msg.payload to msg.payload.ANYNAME

**URL:** <https://discourse.nodered.org/t/change-msg-payload-to-msg-payload-anyname/32180>\
**Category:** General\
**Created:** [29 August 2020 11:19 UTC](https://discourse.nodered.org/t/change-msg-payload-to-msg-payload-anyname/32180 "2020-08-29T11:19:38Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![tobi1011](https://avatars.discourse-cdn.com/v4/letter/t/7feea3/32.png) [@tobi1011](https://discourse.nodered.org/u/tobi1011)\
**Post date:** [29 August 2020 11:19 UTC](https://discourse.nodered.org/t/change-msg-payload-to-msg-payload-anyname/32180/1 "2020-08-29T11:19:38Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [29 August 2020 11:35 UTC](https://discourse.nodered.org/t/change-msg-payload-to-msg-payload-anyname/32180/2 "2020-08-29T11:35:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tobi1011](https://avatars.discourse-cdn.com/v4/letter/t/7feea3/32.png) [@tobi1011](https://discourse.nodered.org/u/tobi1011)\
**Post date:** [29 August 2020 11:52 UTC](https://discourse.nodered.org/t/change-msg-payload-to-msg-payload-anyname/32180/3 "2020-08-29T11:52:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [29 August 2020 12:04 UTC](https://discourse.nodered.org/t/change-msg-payload-to-msg-payload-anyname/32180/4 "2020-08-29T12:04:53Z")

</div>

Look thru this

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/b/2b82ac21fc3d65e9c13dbc46e0e12ce8751c7f69.png)

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 🙂

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [29 August 2020 12:14 UTC](https://discourse.nodered.org/t/change-msg-payload-to-msg-payload-anyname/32180/5 "2020-08-29T12:14:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [29 August 2020 12:32 UTC](https://discourse.nodered.org/t/change-msg-payload-to-msg-payload-anyname/32180/6 "2020-08-29T12:32:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tobi1011](https://avatars.discourse-cdn.com/v4/letter/t/7feea3/32.png) [@tobi1011](https://discourse.nodered.org/u/tobi1011)\
**Post date:** [31 August 2020 07:09 UTC](https://discourse.nodered.org/t/change-msg-payload-to-msg-payload-anyname/32180/7 "2020-08-31T07:09:57Z")

</div>

Thanks a lot!! this solved my issue! 😃 😃  
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 😃  
toby

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [31 August 2020 08:45 UTC](https://discourse.nodered.org/t/change-msg-payload-to-msg-payload-anyname/32180/8 "2020-08-31T08:45:16Z")

</div>

It should work and its a lot more compact

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/9/0940ce654cd70d0354c3a2f9f07909fd9e4eddd2.jpeg)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [14 September 2020 08:45 UTC](https://discourse.nodered.org/t/change-msg-payload-to-msg-payload-anyname/32180/9 "2020-09-14T08:45:32Z")

</div>

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