# How can I make the identifier variable

**URL:** <https://discourse.nodered.org/t/how-can-i-make-the-identifier-variable/92610>\
**Category:** General\
**Created:** [23 October 2024 13:15 UTC](https://discourse.nodered.org/t/how-can-i-make-the-identifier-variable/92610 "2024-10-23T13:15:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChrisWeb71](https://avatars.discourse-cdn.com/v4/letter/c/53a042/32.png) [@ChrisWeb71](https://discourse.nodered.org/u/ChrisWeb71)\
**Post date:** [23 October 2024 13:15 UTC](https://discourse.nodered.org/t/how-can-i-make-the-identifier-variable/92610/1 "2024-10-23T13:15:31Z")

</div>

how can I make the identifier variable  
e.g.

```auto
how can I make the identifier variable
e.g.
var identifier = (msg.topic);

msg.payload = {
""+identifier+"" :msg.payload
}
return msg;

//Unfortunately, this method does not work

```

---

<div class="post-metadata">

**Author:** ![GogoVega](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gogovega/32/71313_2.png) [@GogoVega](https://discourse.nodered.org/u/GogoVega)\
**Post date:** [23 October 2024 13:17 UTC](https://discourse.nodered.org/t/how-can-i-make-the-identifier-variable/92610/2 "2024-10-23T13:17:20Z")

</div>

With:

```js
const identifier = msg.topic;

msg.payload = { [identifier]: msg.payload };

return msg;

```

---

<div class="post-metadata">

**Author:** ![ChrisWeb71](https://avatars.discourse-cdn.com/v4/letter/c/53a042/32.png) [@ChrisWeb71](https://discourse.nodered.org/u/ChrisWeb71)\
**Post date:** [23 October 2024 13:18 UTC](https://discourse.nodered.org/t/how-can-i-make-the-identifier-variable/92610/3 "2024-10-23T13:18:45Z")

</div>

that was quick, thank you very much

---

<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:** [6 November 2024 13:18 UTC](https://discourse.nodered.org/t/how-can-i-make-the-identifier-variable/92610/4 "2024-11-06T13:18:54Z")

</div>

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