Checking on how to get *context* from a subflow

Sorry for asking - again.

But I am stuck.

In a function node.
This is the code that works:

var x = flow.get("$parent.name");
var y = global.get("something");
msg.payload = x + " " + y;

My question is why the inconsistency with the command to access the higher level data?

One is flow.get("$parent.name") and the other is global.get("something")

Could someone show me the proper way to access the flow/global variables?

Oh, and how to access them using a change node? They aren't exactly conducive to those commands.

In a subflow change node you can use the same notation

The reasoning (I suspect) behind it:

global = global, available everywhere.

The subflow can have its own flow variables too (as it is a flow) when trying to get variables you will need to tell it which one.

edit i should have read the "from" word in your title, i'll update in a bit :wink:

1 Like

Thanks.

I am kind of ....... crazy with getting sub-flows built and need to access flow variables too.

I got around the problem by cheating and creating messages before the subflow.

But now knowing this trick, I may go back and make it better.

I think you can't as they exist in their own scope which is not available from another flow (?) then again the subflow can talk to its parent, so the other way around could (or should) perhaps be possible somehow too. But you can always pass them in the message you are sending to the subflow.

perhaps Nick has a better explanation.

Alas it is tricky with the variable in the inbound message.

Not impossible, as I did get it working.

It is just .... well.... it is confusing in some ways for the subflow is happening.

Again: Thanks for the reply and help.