(key: string): any
(all: boolean): any
(arguments: {
all?: boolean,
key?: string,
default?: any,
contextId?: string
}): any
The _global
operator gets a value from the global
object. The global
object is a shared data object that can be accessed from any context
in the app.
Arguments
string
If the _global
operator is called with a string argument, the value of the key in the global
object is returned. If the value is not found, null
is returned. Dot notation and block list indexes are supported.
boolean
If the _global
operator is called with boolean argument true
, the entire global
object is returned.
object
all: boolean
: Ifall
is set totrue
, the entireglobal
object is returned. One ofall
orkey
are required.key: string
: The value of the key in theglobal
object is returned. If the value is not found,null
, or the specified default value is returned. Dot notation and block list indexes are supported. One ofall
orkey
are required.default: any
: A value to return if thekey
is not found inglobal
. By default,null
is returned if a value is not found.contextId: string
: The id of acontext
. Setting this will get the value from thecontext
of the specified context. A list ofcontexts
that exist are returned by the_list_contexts
operator. The value ofglobal
is the same for allcontexts
. Cannot be used inconnections
orrequests
.
Examples
Get the value of my_key
from global
:
_global: my_key
_global:
key: my_key
Returns: The value of my_key
in global
.
Get the entire global
object:
_global: true
_global:
all: true
Returns: The entire global
object.
Dot notation:
Assuming global:
my_object:
subfield: 'Value'
then:
_global: my_object.subfield
_global:
key: my_object.subfield
Returns: "Value"
.
Return a default value if the value is not found:
_global:
key: might_not_exist
default: Default value
Returns: The value of might_not_exist
, or "Default value"
.
Block list indices:
Assuming global
:
my_array:
- value: 0
- value: 1
- value: 2
then:
_global: my_array.$.value
Returns: 0
when used from the first block (0th index) in a list.