# Retrieve the value of a flow variable from another node into the JS file?

**URL:** https://discourse.nodered.org/t/retrieve-the-value-of-a-flow-variable-from-another-node-into-the-js-file/53132
**Category:** Developing Nodes
**Created:** [2 November 2021 15:58 UTC](https://discourse.nodered.org/t/retrieve-the-value-of-a-flow-variable-from-another-node-into-the-js-file/53132 "2021-11-02T15:58:21Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![StefCReSTIC](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@StefCReSTIC](https://discourse.nodered.org/u/StefCReSTIC)
#### Post date: [2 November 2021 15:58 UTC](https://discourse.nodered.org/t/retrieve-the-value-of-a-flow-variable-from-another-node-into-the-js-file/53132/1 "2021-11-02T15:58:21Z")

</div>

Hi everyone !

I'm currently creating a custom node and I have a problem.

Is it possible to retrieve the value of a flow variable from a change node into the js file of my custom node ?

I tried to use flow.get("value") like in custom function but I had this error in node-red: "ReferenceError: flow is not defined".

If someone have an idea please ?

Thanks

---

<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: [2 November 2021 16:12 UTC](https://discourse.nodered.org/t/retrieve-the-value-of-a-flow-variable-from-another-node-into-the-js-file/53132/2 "2021-11-02T16:12:32Z")

</div>

The docs for accessing context from a node are [here](https://nodered.org/docs/creating-nodes/context)

In summary, to access flow context you use:

```auto
let flowContext = this.context().flow
let value = flowContext.get("value")

```

One thing you must be aware of when using context in a custom node is that the user _might_ have configured a context store that requires asynchronous only access. The Change node deals with this under the covers for you, but in your node, you'd need to use the async functions as described [here](https://nodered.org/docs/user-guide/writing-functions#asynchronous-context-access).

---

<div class="post-metadata">

### Author: ![StefCReSTIC](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@StefCReSTIC](https://discourse.nodered.org/u/StefCReSTIC)
#### Post date: [3 November 2021 08:31 UTC](https://discourse.nodered.org/t/retrieve-the-value-of-a-flow-variable-from-another-node-into-the-js-file/53132/3 "2021-11-03T08:31:45Z")

</div>

Thanks a lot knolleary ! It works .

Have a nice day .

---

<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: [17 November 2021 08:31 UTC](https://discourse.nodered.org/t/retrieve-the-value-of-a-flow-variable-from-another-node-into-the-js-file/53132/4 "2021-11-17T08:31:49Z")

</div>

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