Subflows & accessing flow/global variables on a per subflow basis (NOT environment variables)

I've got a subflow that I'm reusing multiple times. I want to access flow/global variables that are created/modified by the subflow. I've successfully created the flow/global variable by using this code in the subflow.

(As you can see, the global variable for each unique subflow is set by $$.topic)

image

How would I go about checking the status (true/false) of that flow/global variable in a subflow. I cant seem to figure it out, on a per topic basis (so it can live in the subflow nicely)?

This seems to work, after a lot of trial and error, but there still is an error below.
image

The error (only seems to error first time).

image

Why not just pass the value to the subflow in the msg? Just before going to the subflow node, add a change node to set msg.???? to the value you want and then in the subflow just get it from the msg.

If it needed updating in the subflow, add a change node just after the subflow to store the value back into the context variable.

Two extra nodes, but it should solve any issues.

Try this syntax

$GlobalContext("motionActive." & $$.topic)
1 Like

Thanks, that's it! I appreciate the help.

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