# Accessing flow context from the subflow

**URL:** <https://discourse.nodered.org/t/accessing-flow-context-from-the-subflow/30467>\
**Category:** General\
**Created:** [21 July 2020 11:49 UTC](https://discourse.nodered.org/t/accessing-flow-context-from-the-subflow/30467 "2020-07-21T11:49:58Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![krzydec](https://avatars.discourse-cdn.com/v4/letter/k/a5b964/32.png) [@krzydec](https://discourse.nodered.org/u/krzydec)\
**Post date:** [21 July 2020 11:49 UTC](https://discourse.nodered.org/t/accessing-flow-context-from-the-subflow/30467/1 "2020-07-21T11:49:58Z")

</div>

Hello

I'm trying to package some of my flows into sub-flows to make it easier to follow.  
One of my function nodes is going through the flow context store using:

> flow.keys()

and delete some variables when they are not needed.  
After packaging this into sub-flows this function stopped working.  
I know that the parent variable can be accessed by using

> flow.get('$parent.' + 'variable\_name');

Is there any option to use keys() function and then to set specific $parent variables to undefined?

Basically, I need to retrieve a list of the parent flow variables to find ones that need deleting and delete them from the sub-flow level.

---

<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:** [21 July 2020 12:04 UTC](https://discourse.nodered.org/t/accessing-flow-context-from-the-subflow/30467/2 "2020-07-21T12:04:38Z")

</div>

Hi - good question. There is no way for a subflow to get the context keys of the parent flow. That scenario has not been considered in the api.

---

<div class="post-metadata">

**Author:** ![krzydec](https://avatars.discourse-cdn.com/v4/letter/k/a5b964/32.png) [@krzydec](https://discourse.nodered.org/u/krzydec)\
**Post date:** [21 July 2020 12:10 UTC](https://discourse.nodered.org/t/accessing-flow-context-from-the-subflow/30467/3 "2020-07-21T12:10:27Z")

</div>

Hi.  
Thank you for prompt response.  
I thought that I do something wrong, now at least I know it's currently unavailable.  
Do you know if this is planned to be included in the future releases?

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [21 July 2020 12:17 UTC](https://discourse.nodered.org/t/accessing-flow-context-from-the-subflow/30467/4 "2020-07-21T12:17:16Z")

</div>

Would it not be possible to build a kind of "interface" using existing nodes?

a) subflow sends a msg with a request to get a list of context keys -\> parent flow responds back with list of context keys

b) subflow sends a msg with request to delete a specific key -\> parent flow deletes key and responds with a confirmation

---

<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:** [21 July 2020 12:19 UTC](https://discourse.nodered.org/t/accessing-flow-context-from-the-subflow/30467/5 "2020-07-21T12:19:04Z")

</div>

> [@krzydec](#):
>
> Do you know if this is planned to be included in the future releases?

Nothing is planned. Until you mentioned it, it hasn't come up at all.

---

<div class="post-metadata">

**Author:** ![krzydec](https://avatars.discourse-cdn.com/v4/letter/k/a5b964/32.png) [@krzydec](https://discourse.nodered.org/u/krzydec)\
**Post date:** [21 July 2020 12:23 UTC](https://discourse.nodered.org/t/accessing-flow-context-from-the-subflow/30467/6 "2020-07-21T12:23:48Z")

</div>

Is there any way of making official request?  
How the decision is made on what is going on the new release?

I understand you can't just add stuff, because some random bloke on the internet is asking for it.

---

<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:** [21 July 2020 12:28 UTC](https://discourse.nodered.org/t/accessing-flow-context-from-the-subflow/30467/7 "2020-07-21T12:28:11Z")

</div>

I've added to the backlog - [https://trello.com/c/JILEMOQ5](https://trello.com/c/JILEMOQ5)

It can be prioritised along with everything else.

---

<div class="post-metadata">

**Author:** ![krzydec](https://avatars.discourse-cdn.com/v4/letter/k/a5b964/32.png) [@krzydec](https://discourse.nodered.org/u/krzydec)\
**Post date:** [21 July 2020 12:34 UTC](https://discourse.nodered.org/t/accessing-flow-context-from-the-subflow/30467/8 "2020-07-21T12:34:35Z")

</div>

I don't see the reason why this wouldn't work, but in my case it's defeating the object of having a subflow.  
Instead of making it simpler it will add complexity.

I will have to send request from the subflow and than inject the results back into input. As there is only one input to the subflow available I will have to manage the messages to get to the right part of the subflow. Alternatively I can have two subflows, but again this will make it more complex than it currently is with my function nodes.

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [21 July 2020 12:39 UTC](https://discourse.nodered.org/t/accessing-flow-context-from-the-subflow/30467/9 "2020-07-21T12:39:44Z")

</div>

Yes, I know, it was just a quick work-around idea but it depends on the urgency. If you have time to wait, then wait until this gets covered from the backlog

---

<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 September 2020 12:39 UTC](https://discourse.nodered.org/t/accessing-flow-context-from-the-subflow/30467/10 "2020-09-19T12:39:44Z")

</div>

Closed on 19 September 2020 12:39 UTC

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