# Global variable undefined in subflow?

**URL:** https://discourse.nodered.org/t/global-variable-undefined-in-subflow/43132
**Category:** General
**Created:** [24 March 2021 17:03 UTC](https://discourse.nodered.org/t/global-variable-undefined-in-subflow/43132 "2021-03-24T17:03:43Z")
**Posts on this page:** 1
**Showing post:** 12

<div class="post-metadata">

### Author: ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)
#### Post date: [24 March 2021 21:09 UTC](https://discourse.nodered.org/t/global-variable-undefined-in-subflow/43132/12 "2021-03-24T21:09:48Z")

</div>

Perhaps you are trying to access the parent context of the subflow ? If this is the case you should test prepending `$parent` to the name of the scope variable.

> [@Subflow context (flow)](https://discourse.nodered.org/t/subflow-context-flow/11534/2):
>
> The nodes in a subflow can use flow context, bit it is scoped to the nodes in the subflow, not the flow the instance of the subflow is on. If you are on 0.20, then the nodes in the subflow can access the parent flow context. If you have a flow context variable called foo then the nodes in a subflow can use $parent.foo to access it.

---

_[View the full topic](https://discourse.nodered.org/t/global-variable-undefined-in-subflow/43132)._
