Hi
I have defined three global variables in the globals section in extensions.ael
The variables represents three phone numbers for the roles we have at our company - sales, support and economy.
globals {
SalesPhone=0709123123;
SupportPhone=0736234234;
EconomyPhone=0702345345;
//clearglobalvars=no; //*
};
*This one has been tried set to no and yes and completely removed - no change
In case some of us is at vaccation or is otherwise busy - I want another phone to be able to answer the calls directed to the corresponding role.
So the person who now should take say the support calls now calls to our asterisk from his mobile. In our IVR-meny he chooses alternative 2 wich is support role.
Now I want to change the SupportPhone-variable to this persons callerid.
2=>{
Noop(Choice - 2 - Support);
&IVR_Selection(1027,2);
Set(SupportPhone=${CALLERID(num)},g);
//__SupportPhone=${CALLERID(num)};
SayDigits(${SupportPhone});
};
Obviously I have tried with both Set with the g option and the double “_” with the same end result. I have even tried the old SetGlobalVar.
The Saydigits function tells me my expected number, but as soon as this call ends the SupportPhone-variable is back to the value defined in the globals section. It behaves like a channel variable or something?
When someone calls our number and chooses to get in touch with the support bransch we do a channelRedirect to corresponding phone variable
ChannelRedirect(${CHANNEL},transfer,${SupportPhone},1);
Any ideas? I’m running this on an asterisk 1.6.1.4 on OpenSuse 11.1 (KDE)
Help much appreciated!
Set() does indeed only change channel variables so the behaviour you’re seeing is correct.
For you application, try using the SetGlobalVar() command (see this website for more info and this website for useful information about variables in general).
Giles.
But it does say:
"Set variable to value in Asterisk v1.0.x and earlier "
and:
"Asterisk 1.2
Use Set instead with the ‘g’ option "
I’m on 1.6.1.
I tired anyway I got this result
"[Aug 19 11:00:29] WARNING[9901]: pbx.c:3167 pbx_extension_helper: No application ‘SetGlobalVar’ for extension (CMLogin, 3, 2)
"
This is the code now…
3=>{
Noop(Choice - 3 - Economy);
SetGlobalVar(EconomyPhone=${CALLERID(num)});
SayDigits(${EconomyPhone});
};
Hi SetGlobalvar started to be removed in 1.2 when it was depriciated , I guess its now gone.
For this type of thing I would use the astdb and store the oncall numbers in the database.
We have done this for oncall systems for support companies and solicitors.
Ian
www.cyber-cottage.co.uk
I suspected that astdb would be my way out - have not worked with it at all though… time to learn something new obviously 
Thanks!
I still do not understand why the global variable can’t be changed though
"Global variables can be set either in the [globals] category of extensions.conf or by using the SetGlobalVar command. Once defined, they can be referenced by any channel at any time. "
And Set with g-option replaces SetGlobalVar.
I now see that if I use the g option the temporary value is set to “phone,g” - it obviously don’t give a crap about the “g” as an option 
IF someone does know of a solution to my problem without astdb please feel free to reply.
THANKS!!!
That did the trick - The global is set!