# Use flow context inside subflow

**URL:** <https://discourse.nodered.org/t/use-flow-context-inside-subflow/48052>\
**Category:** General\
**Created:** [5 July 2021 13:00 UTC](https://discourse.nodered.org/t/use-flow-context-inside-subflow/48052 "2021-07-05T13:00:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sfedo](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@sfedo](https://discourse.nodered.org/u/sfedo)\
**Post date:** [5 July 2021 13:00 UTC](https://discourse.nodered.org/t/use-flow-context-inside-subflow/48052/1 "2021-07-05T13:00:02Z")

</div>

Hello,

is it possible to use context, inside a subflow?

Inside my subflow I try to set flow context as shon in the picture with change node using set.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/0/7083f9597a1c0a96c00e78ed8547abdbdbf35bc0.png)

But when I refresh context tab, nothing apears there. Am I doing something wrong?

---

<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:** [5 July 2021 13:04 UTC](https://discourse.nodered.org/t/use-flow-context-inside-subflow/48052/2 "2021-07-05T13:04:30Z")

</div>

The context sidebar does not show context from inside a subflow.

When you have the subflow open in the editor, you are looking at the template for the subflow. You might have 10 instances of the subflow in your flows, and each has its own `flow` context.

So the context sidebar doesn't know which subflow you want to see the context of.

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [5 July 2021 23:37 UTC](https://discourse.nodered.org/t/use-flow-context-inside-subflow/48052/3 "2021-07-05T23:37:20Z")

</div>

Nick,

Sorry if i am not understanding here - properly.

Can a subflow push back flow variables into the flow that it was called from - or only use the global variables to achieve this ?

Craig

---

<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:** [5 July 2021 23:39 UTC](https://discourse.nodered.org/t/use-flow-context-inside-subflow/48052/4 "2021-07-05T23:39:46Z")

</div>

Inside a subflow, `flow` context is scoped to inside that instance of the subflow.

You can get to the parent flow's context by starting your context key with `$parent.`

For example, if a flow has a flow context property called `flow.color`, then from inside a subflow on that flow, you can reach it with `flow.$parent.color`.

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [5 July 2021 23:53 UTC](https://discourse.nodered.org/t/use-flow-context-inside-subflow/48052/5 "2021-07-05T23:53:39Z")

</div>

Aaah OK thanks - so you can push back values the same way by using flow.$parent.color and going a set or using a change node ?

Craig

---

<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:** [19 July 2021 23:54 UTC](https://discourse.nodered.org/t/use-flow-context-inside-subflow/48052/6 "2021-07-19T23:54:40Z")

</div>

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