Using variables in flow set and get

Hello guys,

Sorry, this is probably something very well known to the more experienced but I couldn't find anything about so here I am.

Is it possible to use indirect referencing to variable names in context/flow/global get and set commands? I have a situation where I'll have around 60 variables that will be read/written to one at a time, and I'd like to use the same function node to do it all.

I'll receive the name of the variable as a string in, here's an example of the kind of logic I'd like to use:

var id =;
var alive = id + "_alive";
var checkalive = flow.get(alive);
var down = id + "_down";
var checkdown = flow.get(down);
flow.set(alive, true);
flow.set(down, false); will always be a 3 char code like IMP, SUP, MTE, etc. So I want to end referencing variables IMP_down, IMP_alive, etc.

Is this possible?

Thank you all!

Yes, you do that in your example with the variable alive

If that is not working, use node.warn('alive = ' + alive) to see what it contains.

1 Like

Forget it, in the rush I was writing to the wrong variable, checkalive instead of alive, and was correctly getting a wrong context key error. I knew it had to be something stupid on my side, I just wasn't findind it.

Thank for the help.

1 Like

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