Setting a different CallerID based on extension

Hey guys, I’m trying to set a callerid based on what extension is calling out… I have tried to do it this way:

;Dial Out with full 10 digit number
exten=>_NXXNXXXXXX,1,NoOp(#### [from-internal] ####)
exten=>_NXXNXXXXXX,2,Set(CALLER_NUMBER=${CALLERID(num)})
exten=>_NXXNXXXXXX,3,NoOp(#### ${CALLER_NUMBER} ####)
exten=>_NXXNXXXXXX,4,Gotoif($["${CALLER_NUMBER}" = "1111111111"]?10:7)
exten=>_NXXNXXXXXX,5,Gotoif($["${CALLER_NUMBER}" = "2222222222"]?13:7)
exten=>_NXXNXXXXXX,6,Gotoif($["${CALLER_NUMBER}" = "3333333333"]?16:7)

exten=>_NXXNXXXXXX,7,Set(CALLERID(num)=0000000000)
exten=>_NXXNXXXXXX,8,Dial(SIP/${EXTEN}@TRUNK)
exten=>_NXXNXXXXXX,9,Hangup()

exten=>_NXXNXXXXXX,10,Set(CALLERID(num)=1111111111)
exten=>_NXXNXXXXXX,11,Dial(SIP/${EXTEN}@TRUNK)
exten=>_NXXNXXXXXX,12,Hangup()

exten=>_NXXNXXXXXX,13,Set(CALLERID(num)=2222222222)
exten=>_NXXNXXXXXX,14,Dial(SIP/${EXTEN}@TRUNK)
exten=>_NXXNXXXXXX,15,Hangup()

exten=>_NXXNXXXXXX,16,Set(CALLERID(num)=3333333333)
exten=>_NXXNXXXXXX,17,Dial(SIP/${EXTEN}@TRUNK)
exten=>_NXXNXXXXXX,18,Hangup()

For some reason, I can’t get it to jump to the right section… it always uses the first callerid with “0000000000”

Any help appreciated.

Thanks.

Use n and s relative priorities, and use ex-girlfriend logic, as suggested, today, for the person who wanted to call a particular number if the caller ID started with particular country codes.

Please also mark your dialplan as pre-formatted text for the forum, as what is actually showing here will use "{CALLERID(num)} and “{CALLER_NUMBER}” as string literals, but I suspect this isn’t the dialplan you are really using.

Assuming there are $ in sensible places, 1111111111 will work, but priorities 5 and 6 will never be reached, because the else branches on 4 bypass them (as, of course, does the then branch).

I think this is the topic referred to.

Sorry about the pre-formatted option… I didn’t think of using that… Now it is displaying correctly but still not working as expected…

Thanks

See my third paragraph.

As it is now… even if extension 1111111111 makes the call… it ends up with callerid 0000000000 on line 7 – it never gets to line 10 where it should be going… so maybe i’m missing something ? or should I be using something like this ?

exten=>_NXXNXXXXXX,4,Gotoif($["${CALLER_NUMBER}" = "1111111111"]?somewhere1,s,1)
exten=>_NXXNXXXXXX,5,Gotoif($["${CALLER_NUMBER}" = "2222222222"]?somewhere2,s,1)


[somewhere1]
exten=>_NXXNXXXXXX,1,Set(CALLERID(num)=1111111111)
exten=>_NXXNXXXXXX,n,Dial(SIP/${EXTEN}@TRUNK)
exten=>_NXXNXXXXXX,n,Hangup()

[somewhere2]
exten=>_NXXNXXXXXX,1,Set(CALLERID(num)=2222222222)
exten=>_NXXNXXXXXX,n,Dial(SIP/${EXTEN}@TRUNK)
exten=>_NXXNXXXXXX,n,Hangup()

Try taking out the spaces.

Took out the spaces… still no luck… got this from the cli log…

Executing [3215551212@from-internal:1] NoOp("SIP/1111111111-000000cb", "#### [from-internal] ####") in new stack
    -- Executing [3215551212@from-internal:2] Set("SIP/1111111111-000000cb", "CALLER_NUMBER=1111111111") in new stack
    -- Executing [3215551212@from-internal:3] NoOp("SIP/1111111111-000000cb", "#### 1111111111 ####") in new stack
    -- Executing [3215551212@from-internal:4] GotoIf("SIP/1111111111-000000cb", "0?10:7") in new stack
    -- Goto (from-internal,3215551212,7)
    -- Executing [3215551212@from-internal:7] Set("SIP/1111111111-000000cb", "CALLERID(num)=0000000000") in new stack
    -- Executing [3215551212@from-internal:8] Dial("SIP/1111111111-000000cb", "SIP/3215551212@TRUNK") in new stack

Try a noop on the expression without the $[]. Something may jump out.

The trace shows the expression is evaluating to false.

Ok, I see what I was doing wrong now… it was evaluating the first expression and coming out false, so it was going to line 7 and not comparing the other lines at all… so I changed my dial plan to this –

exten=>_NXXNXXXXXX,1,NoOp(#### [from-internal] ####)
exten=>_NXXNXXXXXX,2,Set(CALLER_NUMBER=${CALLERID(num)})
exten=>_NXXNXXXXXX,3,NoOp(#### ${CALLER_NUMBER} ####)
exten=>_NXXNXXXXXX,4,Gotoif($["${CALLER_NUMBER}" = "1111111111"]?10)
exten=>_NXXNXXXXXX,5,Gotoif($["${CALLER_NUMBER}" = "2222222222"]?13)
exten=>_NXXNXXXXXX,6,Gotoif($["${CALLER_NUMBER}" = "3333333333"]?16)

Removing the :7 option on each of the lines I force it to go from one to the next to evaluate each one and chose the correct callerid…

Thanks to David for working through this with me until I saw the light! LOL :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.