# Is there a way to get node properties Name and use it later in the flow?

**URL:** <https://discourse.nodered.org/t/is-there-a-way-to-get-node-properties-name-and-use-it-later-in-the-flow/54887>\
**Category:** General\
**Created:** [8 December 2021 17:10 UTC](https://discourse.nodered.org/t/is-there-a-way-to-get-node-properties-name-and-use-it-later-in-the-flow/54887 "2021-12-08T17:10:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![peterda](https://avatars.discourse-cdn.com/v4/letter/p/df705f/32.png) [@peterda](https://discourse.nodered.org/u/peterda)\
**Post date:** [8 December 2021 17:10 UTC](https://discourse.nodered.org/t/is-there-a-way-to-get-node-properties-name-and-use-it-later-in-the-flow/54887/1 "2021-12-08T17:10:57Z")

</div>

I want to use the name of a node later in a flow, is this possible?  
When yes, how can i do this?

![Node-RED-192-168-99-30](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/9/b96ace8d096c2a4aadadacb4699768bb478d4ce1.png)

I am using a zigbee2mqtt node and give it an understandable name.  
This name will be used to commit a record in a database.  
Thus not having to keep track of redundant information.

Thanks, Peter

---

<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:** [8 December 2021 17:23 UTC](https://discourse.nodered.org/t/is-there-a-way-to-get-node-properties-name-and-use-it-later-in-the-flow/54887/2 "2021-12-08T17:23:55Z")

</div>

A long time ago I think someone gave me some JSONata that extracts the name of the node

If this is true, then you could add an JSONAta expression to stick it in something like msg.InjectName

I'll try some searching ....  
[edit] In retrospect, it might have been that a function node can access the name through node.name but I don't know if it can be done using JSONata

---

<div class="post-metadata">

**Author:** ![peterda](https://avatars.discourse-cdn.com/v4/letter/p/df705f/32.png) [@peterda](https://discourse.nodered.org/u/peterda)\
**Post date:** [8 December 2021 20:42 UTC](https://discourse.nodered.org/t/is-there-a-way-to-get-node-properties-name-and-use-it-later-in-the-flow/54887/3 "2021-12-08T20:42:04Z")

</div>

In a function node this works to get it's node name:

```auto
msg.payload = node.name
return msg;

```

A picture says more than ... 🙂

 ![Node-RED-192-168-99-30](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/1/5135854b2419c5e32619db4c3e1cf3c58440a78e.png)

The name will then be used ( i am an new beginner with javascript!!! ) here:

```auto
let obj = [];
let payload = msg.payload;
let ieee_address = msg.device["ieeeAddr"];
let friendly_name = msg.device["friendly_name"];
let location = "office"; /* <- i want the node name here */

obj.push(payload);
obj.push({ieee_address, 
          friendly_name,
          location});

msg.payload = obj;

return msg;

```

This pushes the data into influxdb with the name in the committed record.

Cheers, Peter

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [8 December 2021 20:47 UTC](https://discourse.nodered.org/t/is-there-a-way-to-get-node-properties-name-and-use-it-later-in-the-flow/54887/4 "2021-12-08T20:47:30Z")

</div>

This is no way to access the name property of a node earlier in the flow.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [8 December 2021 20:52 UTC](https://discourse.nodered.org/t/is-there-a-way-to-get-node-properties-name-and-use-it-later-in-the-flow/54887/5 "2021-12-08T20:52:22Z")

</div>

But you could pass the message through a change node which adds msg.source = "garage door"

---

<div class="post-metadata">

**Author:** ![peterda](https://avatars.discourse-cdn.com/v4/letter/p/df705f/32.png) [@peterda](https://discourse.nodered.org/u/peterda)\
**Post date:** [8 December 2021 20:59 UTC](https://discourse.nodered.org/t/is-there-a-way-to-get-node-properties-name-and-use-it-later-in-the-flow/54887/6 "2021-12-08T20:59:09Z")

</div>

Not exactly what i had in mind, but as a workaround it works for me.

Thank you !

---

<div class="post-metadata">

**Author:** ![peterda](https://avatars.discourse-cdn.com/v4/letter/p/df705f/32.png) [@peterda](https://discourse.nodered.org/u/peterda)\
**Post date:** [8 December 2021 21:07 UTC](https://discourse.nodered.org/t/is-there-a-way-to-get-node-properties-name-and-use-it-later-in-the-flow/54887/7 "2021-12-08T21:07:35Z")

</div>

Just found out that i can set the friendly\_name in zigbee2mqtt.  
This will fix it without a hassle...

Edit:  
Using friendly\_name has drawback as well, so please bring on workarounds or a solution.

Thanks, Peter

---

<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 February 2022 21:08 UTC](https://discourse.nodered.org/t/is-there-a-way-to-get-node-properties-name-and-use-it-later-in-the-flow/54887/8 "2022-02-06T21:08:23Z")

</div>

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