# Assigning function node variable to incoming payload naming convention

**URL:** <https://discourse.nodered.org/t/assigning-function-node-variable-to-incoming-payload-naming-convention/54437>\
**Category:** General\
**Created:** [29 November 2021 06:28 UTC](https://discourse.nodered.org/t/assigning-function-node-variable-to-incoming-payload-naming-convention/54437 "2021-11-29T06:28:23Z")\
**Posts on this page:** 3\
**Page:** 1

<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 November 2021 06:28 UTC](https://discourse.nodered.org/t/assigning-function-node-variable-to-incoming-payload-naming-convention/54437/1 "2021-11-29T06:28:23Z")

</div>

I tend to have my first line in my Blocky nodes as

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

assigning a variable called payload to msg.payload

I then do stuff and quite often just change it to something else and then output it

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

I was idling wondering whether it was a "good idea" to use the same name for the variable as the main msg property

Then I started thinking - what else should I call it - data?

Then I thought, do others follow a convention and if so what is it?

And maybe it would be nice idea if we all used the same one when helping out beginners?

_Yes - I'm up early and waiting for a PiZero to update and just had my first drug intake - coffee 🙂_

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [29 November 2021 09:04 UTC](https://discourse.nodered.org/t/assigning-function-node-variable-to-incoming-payload-naming-convention/54437/2 "2021-11-29T09:04:18Z")

</div>

I often go with `data` to improve readability (`payload` vs. `msg.payload`).

For data transformations (resulting in new payload objects) I follow this "pattern":

```auto
let data = msg.payload;

// do sth. with data

let result = ...

msg.payload = result;

return msg;

```

After all, it's all a matter of preference. The important thing is to keep it consistent. 🤓

---

<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:** [28 January 2022 09:04 UTC](https://discourse.nodered.org/t/assigning-function-node-variable-to-incoming-payload-naming-convention/54437/3 "2022-01-28T09:04:22Z")

</div>

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