Skip to main content

12.05 Using global variables

As an example of working with global variables, let's create a scenario, the result of which would be to create a global variable and get a list of all global variables, including the created one.

Three nodes must be added for the scenario to work successfully:

  • (1) Trigger on Run once node to run the scenario after clicking on the Run once button;
  • (2) SetGlobalVariables node to create a global variable TestGlVar2;
  • (3) Node JavaScript with code, to get a list of all existing global variables.
export default async function run({ execution_id, input, data, store }) {
// List Global vars directly from JS

const List = await store.listGlobalVariables()

return {
List
}
}
tip

You can see other examples of using the JavaScript node to work with global variables here.

The result of the scenario execution is the retrieval of all global variables, including the created one.