Custom CallerID not showing in Reports

Before I open a bug report, I want to confirm that I did things correctly.

Basically, I want to modify the caller id number depending on the incoming zap channel. I’m using the following dialing plan

[custom-callerid]
exten => s,1,Gosubif($[${LEN(${CALLERID(num)})} = 7]?set02|1)
exten => s,n,Gosubif($[${LEN(${CALLERID(num)})} = 8]?set0|1)
exten => s,n,Gosubif($["${CHANNEL42}"=“12”]?set1800|1)
exten => s,n,Gosubif($["${CHANNEL42}"=“13”]?set1800|1)
exten => s,n,Gosubif($["${CHANNEL42}"=“10”]?set1800|1)
exten => s,n,Gosubif($["${CHANNEL41}"=“9”]?set1800|1)
include => from-zaptel

exten => set0,1,Set(CALLERID(num)=0${CALLERID(num)})
exten => set0,n,Return
exten => set02,1,Set(CALLERID(num)=02${CALLERID(num)})
exten => set02,n,Return
exten => set1800,1,Set(CALLERID(name)=From 1800)
exten => set1800,n,Return

The zapata context is obviously “custom-callerid”. The caller id gets displayed fine on the phones (grandstream gxp-2000) however the modified caller id doesnt get written to the call reports. Here is the asterisk log file output http//pastebin.ca/558620

Notice how on line 2 the callerID is 7 digits, and on line 7 its has “02” appended (that the way I want it). However on line 492, when the call is entered in the the cdr, the caller ID is back to the original callerID! Did i set something wrong??

Interestingly the callerID name mod (From 1800) shows up just fine in the cdr.

did you try modifying the ANI and see if that makes a difference?

its a zap channel.

you can still set the field and see what happens to the cdr record

I changed the dial plan as follows, and now everything seems ok. Its looks a bit backwards, but its working.

[custom-callerid]
exten => s,1,Gosubif($[${LEN(${CALLERID(num)})} = 7]?set02|1)
exten => s,n,Gosubif($[${LEN(${CALLERID(num)})} = 8]?set0|1)
exten => s,n,Gosubif($["${CHANNEL:4:2}"=“12”]?set1800|1)
exten => s,n,Gosubif($["${CHANNEL:4:2}"=“13”]?set1800|1)
exten => s,n,Gosubif($["${CHANNEL:4:2}"=“10”]?set1800|1)
exten => s,n,Gosubif($["${CHANNEL:4:1}"=“9”]?set1800|1)
include => from-zaptel

exten => set0,1,Set(CALLERID(ANI)=0${CALLERID(num)})
exten => set0,n,Set(CALLERID(num)=0${CALLERID(num)})
exten => set0,n,Return
exten => set02,1,Set(CALLERID(ANI)=02${CALLERID(num)})
exten => set02,n,Set(CALLERID(num)=02${CALLERID(num)})
exten => set02,n,Return
exten => set1800,1,Set(CALLERID(name)=From: 1800)
exten => set1800,n,Return