# Access variables in flow without connecting it (function)

**URL:** <https://discourse.nodered.org/t/access-variables-in-flow-without-connecting-it-function/44926>\
**Category:** General\
**Created:** [29 April 2021 10:28 UTC](https://discourse.nodered.org/t/access-variables-in-flow-without-connecting-it-function/44926 "2021-04-29T10:28:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![AxelD](https://avatars.discourse-cdn.com/v4/letter/a/b77776/32.png) [@AxelD](https://discourse.nodered.org/u/AxelD)\
**Post date:** [29 April 2021 10:28 UTC](https://discourse.nodered.org/t/access-variables-in-flow-without-connecting-it-function/44926/1 "2021-04-29T10:28:51Z")

</div>

Hey guys!

In my function i want to have access to other variables. I want to send a string to my function without connecting it. In the inject node is a string "Axel" and I send this to a change node en change the msg. to flow.name. How do I access this variable in the Function?

Thank you and kind regards,  
AxelD

 ![afbeelding](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/8/38fbf0f6ce9c0e3067fa7b2fb6290540e641b44d.png)

![afbeelding](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/1/7104cc0550573c7d087e7ac4a6dd1d25fa694a9e.png)

![afbeelding](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/2/62aebe3fef5d34e586d489f075e4b2e98207f1ae.png)

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

![afbeelding](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/7/877524925769785cf4a7992a164499f4236de43c.png)

---

<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:** [29 April 2021 10:31 UTC](https://discourse.nodered.org/t/access-variables-in-flow-without-connecting-it-function/44926/2 "2021-04-29T10:31:28Z")

</div>

At the moment your change node is setting `msg.payload` to the value of `flow.name`. If you meant to set `flow.name` to the value of `msg.payload` you need to swap around those to fields in the Change node.

---

<div class="post-metadata">

**Author:** ![AxelD](https://avatars.discourse-cdn.com/v4/letter/a/b77776/32.png) [@AxelD](https://discourse.nodered.org/u/AxelD)\
**Post date:** [29 April 2021 10:34 UTC](https://discourse.nodered.org/t/access-variables-in-flow-without-connecting-it-function/44926/3 "2021-04-29T10:34:11Z")

</div>

Then I get this message in the debug.

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

---

<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:** [29 April 2021 10:50 UTC](https://discourse.nodered.org/t/access-variables-in-flow-without-connecting-it-function/44926/4 "2021-04-29T10:50:18Z")

</div>

> [@AxelD](#):
>
> Then I get this message in the debug

Is that not what you want?

---

<div class="post-metadata">

**Author:** ![AxelD](https://avatars.discourse-cdn.com/v4/letter/a/b77776/32.png) [@AxelD](https://discourse.nodered.org/u/AxelD)\
**Post date:** [29 April 2021 11:35 UTC](https://discourse.nodered.org/t/access-variables-in-flow-without-connecting-it-function/44926/5 "2021-04-29T11:35:25Z")

</div>

No not realy, but I just found the answer I was looking for.  
Thanks anyway!

 ![afbeelding](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/6/16645d089bcc12947f85db749c7cd45e148febe4.png)

![afbeelding](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/e/0ef376dd5bd12f39071947460bcee9a1753776dd.png)

![afbeelding](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/3/03a1639019eb61d1991491b91a2fda04c62c0ff5.png)

---

<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:** [29 April 2021 11:37 UTC](https://discourse.nodered.org/t/access-variables-in-flow-without-connecting-it-function/44926/6 "2021-04-29T11:37:39Z")

</div>

The Function node that does `global.set("test24", msg.payload)` could be a Change node configured to set `global.test24` to the value of `msg.payload`.

The second Function node could be a Change node configured to set `msg.payload` to the value of `global.test24`.

---

<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:** [13 May 2021 11:38 UTC](https://discourse.nodered.org/t/access-variables-in-flow-without-connecting-it-function/44926/7 "2021-05-13T11:38:29Z")

</div>

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