Need help with outboundcid

Hello,

I have been running Freepbx for over a year now, and I am very happy. So far, I could help myself, or just with a search of the forums.
But now I want to do something slightly different, that is have a different caller id (loaded from mysql) for one of the trunks.
I did change the mysql layout and the relevant file in the core module (may have to look for a better way to deal with updates).

My issue comes with the extension_override. I need to select the right callerid, and somehow, it is not working.

From extensions_override_freepbx.conf:

[macro-outbound-callerid]
include => macro-outbound-callerid-custom
exten => s,1,ExecIf($["${CALLINGPRES_SV}" != ""]?Set(CALLERPRES()=${CALLINGPRES_SV}))
exten => s,n,ExecIf($["${REALCALLERIDNUM:1:2}" = ""]?Set(REALCALLERIDNUM=${CALLERID(number)}))
exten => s,n(start),GotoIf($[ $["${REALCALLERIDNUM}" = ""] | $["${KEEPCID}" != "TRUE"] | $["${OUTKEEPCID_${ARG1}}" = "on"] ]?normcid)
exten => s,n,Set(USEROUTCID=${REALCALLERIDNUM})
exten => s,n,GotoIf($["foo${DB(AMPUSER/${REALCALLERIDNUM}/device)}" = "foo"]?bypass)
exten => s,n(normcid),ExecIf($["${ARG1}" = 2]?Set(USEROUTCID=${DB(AMPUSER/${AMPUSER}/outboundcidsip)}:Set(USEROUTCID=${DB(AMPUSER/${AMPUSER}/outboundcid)})

Everything after the last line is identical. ${ARG1} should be the DIAL_TRUNK variable passed to the macro outbound-callerid.
If it is 2, then I use the field outboundcidsip, otherwise outboundcip.

It appears, though, that even if the DIAL_TRUNK is 2, it uses outboundcip regardless.

From the logs:

[Jun 16 15:56:16] VERBOSE[10433] pbx.c:     -- Executing [[email protected]:1] Set("SCCP/03-00000002", "DIAL_TRUNK=2") in new stack
[Jun 16 15:56:16] VERBOSE[10433] pbx.c:     -- Executing [[email protected]:2] GosubIf("SCCP/03-00000002", "0?sub-pincheck,s,1") in new stack
[Jun 16 15:56:16] VERBOSE[10433] pbx.c:     -- Executing [[email protected]:3] GotoIf("SCCP/03-00000002", "0?disabletrunk,1") in new stack
[Jun 16 15:56:16] VERBOSE[10433] pbx.c:     -- Executing [[email protected]:4] Set("SCCP/03-00000002", "DIAL_NUMBER=YYYYYYYYYYYY") in new stack
[Jun 16 15:56:16] VERBOSE[10433] pbx.c:     -- Executing [[email protected]:5] Set("SCCP/03-00000002", "DIAL_TRUNK_OPTIONS=tr") in new stack
[Jun 16 15:56:16] VERBOSE[10433] pbx.c:     -- Executing [[email protected]:6] Set("SCCP/03-00000002", "OUTBOUND_GROUP=OUT_2") in new stack
[Jun 16 15:56:16] VERBOSE[10433] pbx.c:     -- Executing [[email protected]:7] GotoIf("SCCP/03-00000002", "1?nomax") in new stack
[Jun 16 15:56:16] VERBOSE[10433] pbx.c:     -- Goto (macro-dialout-trunk,s,9)
[Jun 16 15:56:16] VERBOSE[10433] pbx.c:     -- Executing [[email protected]:9] GotoIf("SCCP/03-00000002", "0?skipoutcid") in new stack
[Jun 16 15:56:16] VERBOSE[10433] pbx.c:     -- Executing [[email protected]:10] Set("SCCP/03-00000002", "DIAL_TRUNK_OPTIONS=") in new stack
[Jun 16 15:56:16] VERBOSE[10433] pbx.c:     -- Executing [[email protected]:11] Macro("SCCP/03-00000002", "outbound-callerid,2") in new stack
[Jun 16 15:56:16] VERBOSE[10433] pbx.c:     -- Executing [[email protected]:1] ExecIf("SCCP/03-00000002", "0?Set(CALLERPRES()=)") in new stack
[Jun 16 15:56:16] VERBOSE[10433] pbx.c:     -- Executing [[email protected]:2] ExecIf("SCCP/03-00000002", "0?Set(REALCALLERIDNUM=ZZ)") in new stack
[Jun 16 15:56:16] VERBOSE[10433] pbx.c:     -- Executing [[email protected]:3] GotoIf("SCCP/03-00000002", "1?normcid") in new stack
[Jun 16 15:56:16] VERBOSE[10433] pbx.c:     -- Goto (macro-outbound-callerid,s,6)
[Jun 16 15:56:16] VERBOSE[10433] pbx.c:     -- Executing [[email protected]:6] ExecIf("SCCP/03-00000002", "0?Set(USEROUTCID=:Set(USEROUTCID=XXXXX")$
[Jun 16 15:56:16] VERBOSE[10433] pbx.c:     -- Executing [[email protected]:7] Set("SCCP/03-00000002", "EMERGENCYCID=") in new stack
[Jun 16 15:56:16] VERBOSE[10433] pbx.c:     -- Executing [[email protected]:8] Set("SCCP/03-00000002", "TRUNKOUTCID=") in new stack
[Jun 16 15:56:16] VERBOSE[10433] pbx.c:     -- Executing [[email protected]:9] GotoIf("SCCP/03-00000002", "1?trunkcid") in new stack

USEROUTCID=XXXXX is the outboundcip, not outboundcipsip

Can anyone help?

Thanks,

Dan.

From quick glance the bug is probably not putting double quotes around the “2”

However…

I would suggest you approach this differently. By doing it this way, you are making your code very fragile to upgrades in a part of the dialplan that is very critical to all calling functions.

Instead, you may want to define “macro-dialout-trunk-predial-hook” which is called just before any call is completed and after all “decisions” about CID for that trunk have been determined.

In that macro you can make the determination (based on trunk or other factors) and make the change there. By doing this you will not have issues with FreePBX upgrades. That macro is not defined by FreePBX and is there specifically for you to do things like this where we won’t break you in the future.

I tried both with and without double quotes, and neither works.

What variables would I use in “macro-dialout-trunk-predial-hook”? I would need to get the trunk number, and the CID…

Thanks,

Dan.

Please ignore - I just realized this is a core dump file… Back to the drawing board.