Currently I had created a global variable as "global.glo" = 1. And if I want to get this global variable by using a
switch node or
change node. Do you have any idea on how to do it? I can't find any example for getting global variable with these nodes.
Thanks & Regards.
Have a look at the docs, specifically the "Using context in a flow" section.
The user guide and the Cookbook are always worth reading. Most of the concepts are explained there nicely.
This link only show how to set and delete context in a flow. Doesn't teach how to read or get from flow or global.
Works the same way. You can use a change node to assign the context value to a message property.
Sorry, I don't know whether this way correct to read or not.
Use "Set" to assign one property value to another (as in the screenshot I provided).
The example posted by @kuema sets msg.payload to current value of the global variable, so effectively it reads the global into msg.payload.
Also, in a Function node you can use
global.get() to read a global into a variable.
Thank you Colin for the info, I tried to get from a function node and it's work.
The link posted earlier links to the writing functions page which explains how to use context in a function node in more detail
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.