same => n,GotoIf($["{ACCOUNTCODE}" != "CONTEXT"]:)
And am wondering if I have made this correct. What I am hoping for is, GoTo the context rule “CONTEXT” if the returned value of the $ACCOUNTCODE lookup matches the [CONTEXT], if there is no match, go to the next line in the current rule.
so basically GoTo the context that matches the value of $ACCOUNTCODE, if no match then just keep moving down the dialplan. Thanks for any input.
That is very garbled. Going to the context named after the account code would be:
same => n, GoTo(${ACCOUNTCODE},${EXTEN},1)
I’m not sure how you handle the possibility that the context dosn’t exist. I’m not sure if the i extension is used for GoTo. You might be able to do it with TryExec.
Your code reduces to GotoIf(1:) which is missing a required question mark
pbx11*CLI> core show function DIALPLAN_EXISTS
-= Info about function 'DIALPLAN_EXISTS' =-
[Synopsis]
Checks the existence of a dialplan target.
[Description]
This function returns '1' if the target exits. Otherwise, it returns '0'.
[Syntax]
DIALPLAN_EXISTS(context[,extension[,priority]])
I had previousy used the GoTo as you suggested just fine. But want to setup the dialplan rule in such a way that basically only one $ACCOUNTCODE jumps to a different context in the dialplan. All others should resume flow normally. I thought GoToIf would be able to do this. Which is why I do not want to use GoTo.
if I wanted to just continue for the GoToIf for a non-matching $ACCOUNTCODE lookup, should that look something like this:
same => n,GotoIf($[“{ACCOUNTCODE}” != “CONTEXT”]?continue)
same => n(continue),andwhateverwasgoingtohappennext
`
I was not aware of this function check. but I do not believe its installed?
ast*CLI> core show functions like [DIALPLAN_EXISTS]
Matching Custom Functions:
--------------------------------------------------------------------------------
0 matching custom functions installed.
when I run core show function DIALPLAN_EXISTS I get the output you provided. but I am not familiar with this tool, and I am not sure if I am using it right, or as it seems, we dont have it setup.
thought I do know the context I want to jump to exists, I know the accountcode I was to use as the “filter” exists. and I know I have the query functioning and configured properly in func_odbc. I just cant seem to get the GoToIf correct to move to the context in the dialplan.
As a whole, this does not make sense as the true branch goes explicitly to the next priority and the false branch goes implicitly to it, so the whole GOTO has no effect.
So here is what I wound up coming with, that works for what I wanted to do:
same => n,GotoIf($["${ACCOUNTCODE}" != "CONTEXT"]?:CONTEXT,${EXTEN},1)
this looks up an accountcode variable from our DB. if the returned value is CONTEXT then it jumps to that context in the dialplan and continues from there. If the returned value is anything else it moves on to the next rule in the same context. tested it and works great. thanks for the input.