I want to set a variable at the start of a context, regardless of the extension dialed. (My PBX is using two-digit extensions.) I tried:
[mycontext]
exten = _X.,1,Set(MYVAR=123)
exten = _XX,1,Goto(anotherplace,1)
include = othercontext
[othercontext]
exten = anotherplace,1,...
I thought it would match the first line, set the variable, and then match the second, but as you all know that doesn’t work because the pattern match sort matches on _XX first and it goes right to [othercontext] without setting the variable. I read that “include” statements effectively break up the pattern sorting, so I tried this:
[mycontext]
exten = _X.,1,Set(MYVAR=123)
include = mycontext_part_two
[mycontext_part_two]
exten = _XX,1,Goto(anotherplace,1)
include = othercontext
[othercontext]
exten = anotherplace,1,...
…my expectation was that it would set the variable, and then match on the exten = _XX
inside mycontext_part_two. Instead it set the variables as expected, and then went right to Hangup.
Is there a better way to create an “always do <something> at the start of a context”?
Regardless, what am I misunderstanding about the dialplan flow here?
Thanks!