dialplan nested if ?

giulianoz

Neuer User
Mitglied seit
27 Jul 2010
Beiträge
7
Punkte für Reaktionen
0
Punkte
0
Hello,
Sorry, I don't speak german even if I understand it a little. I'm going crazy about the following diaplan entry:

exten => s,n,Set(tmp_callerid=${CALLERID(number)})
exten => s,n,Set(CALLERID(number)=${IF($[ ${tmp_callerid} = +1234567890]?${IF($[ ${LEN(${OUTNUM})} = 3 ]?123:01234567)}:${tmp_callerid})


what I'd like to do (the call is originated by a mobile phone over a sip trunk and it sends the callerid(number) set to its sim number)
:
* check if the callerid(number) is my number (ie:+391234567890)
* if the OUTNUM is an internal one (length=3) -> change the callerid(number) to my internal phone number (ie:123)
* otherwise the dialed number is an external one so I set the callerid(number) to my isdn public number

What I get:
* CALLERID(name) is set to nothing no matter what number I dial

but I can't see what's wrong.
Can someone help me please ?

TIA

giuliano
 
If I understood You right, the following snippet should do the trick (sometimes an easier construction may be more helpful than trying to nest all decisions within one line ;)):

Code:
exten => s,n,Set(tmp_callerid=${CALLERID(number)})
exten => s,n,GotoIf($["${tmp_callerid}"="+1234567890"]?mycid:notmycid)
exten => s,n(mycid),GotoIf($[${LEN(${OUTNUM})}=3]?intern:extern)
exten => s,n(intern),Set(CALLERID(num)=123)
exten => s,n,Goto(ende)
exten => s,n(extern),Set(CALLERID(num)=01234567)
exten => s,n,Goto(ende)
exten => s,n(notmycid),NoOp(Whatever to Do with nonverified cid)
exten => s,n(ende), NoOp(Whatever to Do with verified cid)

Hope it helps!
 
What about this?

Code:
exten => s,n,Set(mycid=${IF($[${LEN(${OUTNUM})}=3]?123:01234567)})
exten => s,n,Set(CALLERID(number)=${IF($["${CALLERID(number)}"="+1234567890"]?${mycid}:${CALLERID(number)})

First check the length of OUTNUM and save the new CID to a variable in case we need it later.
Then check the CID. If it's yours, then set it to the previous set variable. If not, just re-set it.
That's the same done in two lines what you had in one.

Remember the quotes in the second IF, the plus sign might cause trouble otherwise.

Nevertheless, abw1oim's solution offers the possibility to for example do something else if the CID matches.
 
thanks for the hint rentier-s. I've decided to go with abw1oim solution because I have to check for multiple callerids with possible different lengths for internal numbers. Also I can set the callerid(name) at the same time

giuliano
 
Kostenlos!

Statistik des Forums

Themen
248,885
Beiträge
2,303,949
Mitglieder
378,564
Neuestes Mitglied
warumdas