[asterisk-users] hwo to stok variable wiith menu

Dale Noll dnoll at wi.rr.com
Fri Nov 25 09:58:29 CST 2011



On 11/25/2011 09:32 AM, salaheddine elharit wrote:
> hello list,
> i have created one menu like below all work without issue, what i want 
> to do is ,
> when the customer press  3 in menu context  exten => 
> 3,1,Goto(support,s,1) i want to stok this variable (3) in database or 
> file instead to go to support context
>

You can save a value to a global variable like you did within your 
sample dialplan, although I do not recommend this approach, you should 
read the note below as to why.

You can save a value to a channel variable with the Set() command and 
use it later within the same call.

You can save a value into the AstDB with the Set(${DB())) and access the 
value from any channel even after an Asterisk restart.

You can setup ODBC, func_odbc and  a database then access the variables 
via the functions defined within the func_odbc.conf

The method you choose should be determined by your needs.


Note:  You set the global variable at the start of your dialplan. This 
global variable is available to ALL channels. If you set it for every 
call, you are doing so needlessly.  If you have multiple applications 
accessing the same variable and each one sets it with a different value, 
you will have problems. Global variables should be used to store 
information needed in the majority of calls.  The way you are using the 
global variable, I believe you may be better off removing the 
SetGlobalVar() call and instead set the variable in the [globals] 
section of extensions.conf.


I hope that helps.

Dale

-- 
"The truth speaks for itself. I'm just the messenger."
      Lyta Alexander - Babylon 5




More information about the asterisk-users mailing list