Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Global variables are variables that don't live on one particular channel — they pertain to all calls on the system. They have global scope. There are two ways to set a global variable. The first is to declare the variable in the [docs:globals] section of extensions.conf, like this:

Code Block
langjavascript
[globals]
MYGLOBALVAR=somevalue

You can also set global variables from dialplan logic using the GLOBAL() dialplan function along with the Set() application. Simply use the syntax:

Code Block
langjavascript
exten=>6124,1,Set(GLOBAL(MYGLOBALVAR)=somevalue)

To retrieve the value of a global channel variable, use the same syntax as you would if you were retrieving the value of a channel variable.