Get Global Node
Overview
The Get Global Node is used to retrieve a global value that is shared across all graphs and subgraphs. The ID of the global value is configured in this node.
The node can be configured to retrieve the value on demand, which means it will be read when nodes need it, rather than when this node executes. This is useful when the global value might change during the execution of the graph.
The node can also be configured to wait until the variable is available. This is useful when the global value is set by another node that might not have completed its execution when this node runs.
- Inputs
- Outputs
- Editor Settings
Inputs
Title | Data Type | Description | Default Value | Notes |
---|---|---|---|---|
Variable ID | string | The ID of the global variable to retrieve. This input is only available if the "Use Input" toggle is checked. | N/A | The input will be coerced into a string if it is not a string. |
Outputs
Title | Data Type | Description | Notes |
---|---|---|---|
Value | (any) | The value of the global variable. | The data type of the output will be the same as the data type of the global variable. |
Editor Settings
Setting | Description | Default Value | Use Input Toggle | Input Data Type |
---|---|---|---|---|
Variable ID | The ID of the global variable to retrieve. | (required) | Yes | string |
Data Type | The data type of the global variable. | string | No | N/A |
On Demand | If enabled, the global variable will be read when nodes need it, rather than when this node executes. Cannot be used with "Wait". | True | No | N/A |
Wait | If enabled, the node will wait until the variable is available. Cannot be used with "On Demand". | False | No | N/A |
Example 1: Retrieve a global variable
- Add a Set Global Node to the graph. Set the variable name to
myGlobalVariable
and the value toHello World
using a Text Node. - In a separate part of the graph, add a Delay Node and set the delay to
1000
(1 second). - Create a Text Node and set the text to
myGlobalVariable
. Pass the text into the Delay Node. - Create a Get Global Node, enable the input for "Variable Name", and pass the output of the Delay Node into the input. Disable the "On Demand" setting.
Example 2: Retrieve a global variable on-demand
- Add a Set Global Node to the graph. Set the variable name to
myGlobalVariable
and the value toHello World
using a Text Node. - Add a Get Global Node and set the variable name to
myGlobalVariable
. Enable the "On Demand" setting. - Add an If Node. Set the
If
input to the Set Global Node, and set theValue
input to the Get Global Node. This will wait for both nodes to complete before running, and will pass the Get Global Node's value through to the next node. - Add a Text Node and connect the If Node to the Text Node.
- Run the graph. Notice that the value of the If node is
Function<string>
because the "On-Demand" setting has been enabled, causing the value to not have resolved yet. The value is resolved in the Text Node, and "Hello World" is displayed.
Error Handling
The Get Global Node will error if the global variable is not found and the Wait
setting is disabled. If the Wait
setting is enabled, the node will wait until the variable is available.
FAQ
Q: What is a global variable?
A: A global variable is a value that is shared across all graphs and subgraphs. It is set using a Set Global Node and retrieved using a Get Global Node.
Q: Can I set a global variable from a parent application?
A: No, global variables can only be set from within the graph. Use a Context Node instead to access global variables set by the parent application.
Q: What happens if the global variable is not found?
A: If the global variable is not found and the Wait
setting is disabled, the Get Global Node will return the default value for the data type selected. For example, if the data type is set to string
, the default value will be an empty string. If the Wait
setting is enabled, the node will wait until the variable is available before returning the value.