Calling Environment Variables in Change Node for Global Variable name

Hello Everyone,

I am building a flow that contains a large amount of subflows. Within these subflows you find one node named ArrayDefect"X". X being an identifier. I have to set these array for each individual machine that I add to this flow. We have around 80+ machines at our plant.

QUESTION: Is there a way to use an environment variable or pass a variable on to the end of these nodes that I can specify per subflow as a 1, 2, 3, 4, etc. ? That way when I just copy and paste all I have to do is add an environment variable of the number I want and just reference that number? I know its possible to set a environment variable in the value field but is it possible in the naming field?

image
image

Thank you!

Not sure of sturcture of ArrayDefect, but if it is an object or array, you can do.


Otherwise you would have to use a function node.

let envr = env.get("evr_name") ?? "0";
msg["ArrayDefect" + envr] = msg.payload;
return msg;

You cannot replace part of an input value with an env variable - from the docs:

This only works if it replaces the entire property - it cannot be used to substitute just part of the value. For example, it is not possible to use CLIENT-${HOST} .

Use a function node instead.

Could you send me a flow id of you getting this to work. I keep getting undefined when calling the global variable.

nvm I was able to get this to work. Thank you!

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