Summary:ASTERISK-17316: On cdr table Caller number in not being stored in clid and src, instead extension number is on outgoing calls.
Reporter:Cidi Rome (cidirome)Labels:
Date Opened:2011-01-29 19:15:38.000-0600Date Closed:2015-03-13 19:04:02
Versions:Frequency of
Description:On version 1.6.x the cdr table used to store the caller number in the fields clid and source on outgoing calls.

Now in version 1.8(.2.3) only the extension is stored on both those fields.

I think at least clid should have the caller number.
Comments:By: Leif Madsen (lmadsen) 2011-01-31 15:07:57.000-0600

Please provide additional information.

* dialplan in use
* output of the console with debug level logging
* CDR output showing what you expect it to look like, and how it really looks

We need to be able to reproduce this issue, so please provide the information that allows this.

By: Cidi Rome (cidirome) 2011-01-31 17:24:26.000-0600

Sorry, I'm new to this.

Anyway, I installed asterisk and freepbx, and to be true, I've been earing about dialplans but don't know what they are or do.

About de console output, I will try to remender when I make the next call to record it.

About the CDR output, I explained:
on outgoing calls in the asteriskcdrdb database, table cdr, the columns source and clid used to store the outgoing number used by the trunk to make the call now both store the extesion used.
I think at least one (probably clid) should store the outgoing number.

By: Vadim Mikhnevych (vmikhnevych) 2011-02-01 03:34:55.000-0600

We've encountered something similar - after CallerID is set in dialplan, it is not stored in CDRs. Also at

Sample dialplan (pstn is a peer of pstn gataway, some digits replaced by xxx for privacy):

exten => _X.,1,NoOp(Test call)
same => n,Set(CALLERID(all)="Caller" <0287610xxx>)
same => n,Dial(SIP/00380505556xxx@pstn,60)
same => n,Hangup

Console output:

== Using SIP RTP CoS mark 5
   -- Executing [00380505556xxx@PHBX_165:1] NoOp("SIP/2011-00000009", "Test call") in new stack
   -- Executing [00380505556xxx@PHBX_165:2] Set("SIP/2011-00000009", "CALLERID(all)="Caller" <0287610xxx>") in new stack
   -- Executing [00380505556xxx@PHBX_165:3] Dial("SIP/2011-00000009", "SIP/00380505556xxx@pstn,60") in new stack
 == Using UDPTL CoS mark 5
 == Using SIP RTP CoS mark 5
   -- Called 00380505556xxx@pstn
   -- SIP/pstn-0000000a is ringing
 == Spawn extension (PHBX_165, 00380505556xxx, 3) exited non-zero on 'SIP/2011-00000009'
      > [INSERT INTO ast_cdr ("calldate","clid","src","dst","dcontext","channel","dstchannel","lastapp","lastdata","duration","billsec","disposition","amaflags","accountcode","uniqueid") VALUES ('2011-02-01 10:59:05','"Caller" <260>','260','00380505556xxx','PHBX_165','SIP/2011-00000009','SIP/pstn-0000000a','Dial','SIP/00380505556xxx@pstn,60',9,0,'NO ANSWER',3,'2011','1296550745.9')]

Caller sip peer configuration:

callerid="Caller" <260>

By: Vadim Mikhnevych (vmikhnevych) 2011-03-16 05:05:34

Any progress about this issue? I suppose it's an important one, as it affects CDRs. And? as a workaround, it's impossible to set CDR(clid) directly because it's read-only.

By: Vadim Mikhnevych (vmikhnevych) 2011-07-04 04:11:24.400-0500

Still exists in 1.8.5-rc1

By: Vadim Mikhnevych (vmikhnevych) 2011-08-29 04:17:06.320-0500

I've found that this is actually not a bug, but a feature. Here is what http://www.voip-info.org/wiki/view/Asterisk+func+callerid says:

Upgrading to Asterisk 1.4
The behavior of the "clid" field of the CDR has always been that it will
contain the callerid ANI if it is set, or the callerid number if ANI was not
set. When using the "callerid" option for various channel drivers, some
would set ANI and some would not. This has been cleared up so that all
channel drivers set ANI. If you would like to change the callerid number
on the channel from the dialplan and have that change also show up in the
CDR, then you *must* set CALLERID(ANI) as well as CALLERID(num).

That's strange a bit (I mean, "to Asterisk 1.4") , because 1.6 had no such behaviour, but for 1.8 setting CALLERID(ANI-num) to caller number value solves the problem with CDRs. Would be nice to have this mentioned in CALLERID() documentation in asterisk.

By: Cidi Rome (cidirome) 2011-11-26 12:22:56.099-0600

Hi there.

Today I came back to this post because I'm traying Asterisk 1.8 again and dealing with the same issue (again):
Now I have Asterisk and the described issue is back.

Last time I went back to version 1.6 not because of this problem, but because of chan_mobile crashing my linux box.

I see that Vadim has undestood the problem and seems to know what is necessary to solve it.

Can someone, please, make some kind of howto on the way of solving this problem? I'm don't heve enough expertise to be able to do it all by myself...

Best Regards.

By: Matt Jordan (mjordan) 2015-03-13 19:04:02.464-0500

As pointed out on this issue, there is a workaround already readily available. Setting the {{CALLERID}} properties on the channel using name/ANI will update the underlying CDR. Alternatively, you can add additional CDR fields to a record using the {{CDR}} function and one of the many adaptive CDR backends.

Finally, altering CDR behaviour is unlikely to occur without a very good reason and a patch.