Saving flow.variables from a Subflow?

I am using Node0Red V1.04. I am able to save global variables from a subflow but saving flow variables does not seem to work.

Is setting / saving flow variables supported from a sub flow?

A flow variable from the context of the subflow is a variable that is only available within the subflow itself as it is flow. So setting it works no problem but only nodes within the subflow itself will be able to see and retrieve it. So its a scope issue as a subflow has its own flow context separate to the one its deployed in. Unfortunately its not possible to see the context within a subflow from the context browser tab.

Johannes

OK, i think I got it now. Many thanks!

I have spent hours trying to browse it both from the subflow and from the main flow where it is used. So theoretically, I should be able to browse it from the subflow (as you I believe that you are saying it exists), but I guess unfortunately this functionality has not been implemented in the context browser? Did I understand this correctly?

So if I want to use a node or flow variable, so as not to expose it to the "outside world", I guess I could do that, but it would be difficult to troubleshoot?

Would you know if implementing context (node or flow) browsing within a subflow is being considered as a planned enhancement? Would it make sense to have this capability or is there a better way of doing this?

This won’t work as you are not looking at the deployed subflow when editing it. It’s more like you are looking at the template the subflow will be made from when you deploy it in a flow. So each instance of the subflow you deploy will have its own flow scope that it can save context to.

For development and debugging you can add an additional output and a function node that sends out the saved flow context vars to that output on a certain debug input msg

I know there was a discussion about this before but I’m not sure if any solution was reached. Maybe @dceejay or @knolleary know if there is an item for context browsing of Subflow instances in the backlog.

Johannes

Yes it's in the backlog to address viewing the context for a particular subflow instance in the sidebar.

1 Like

Thanks for the responses. You have provided some work arounds and it sounds like a future resolution is planned.

I am all set for now and will try some of the suggestions. Thank you.

1 Like

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