CDR Problem In Asterisk

Hi, I have a problem on setting the CDR(userfield) it is always empty what ever i did, not work.

Sample usage is :

exten => s,1,AGI(dial.php|someparameter,someotherparameter)
exten => s,n,Set(CDR(userfield)=Value)
exten => s,n,Hangup

Also in cdr_mysql.conf userfield has been set to ‘1’

Besides this i think the duration and billsec values in the cdr table is not correct.

Any ideas?

This is going to depend on what the AGI script does. However, the name suggests that it dials, which may mean that you are setting the userfield too late.

If bill seconds and duration appear wrong, it is probably because you don’t understand what they mean. In particular, they relate to the incoming, not the outgoing call, so they only give valid information for the outgoing call if you don’t answer the incoming call and initiate the outgoing call immediately. You can use ResetCDR (definitely) and ForkCDR (possibly) to allow you to separate incoming and outgoing times.

Having said that, CDRs do not work well for complex calls, and there is a radically different mechanism, call event logging, in the development version.

In my application i make calls to some numbers and play a message to those numbers. The call logs are logged only in CDR table so i have to access those records in order to relate to the campaign. So i am trying to set the userfield to the campaign id of the call. However i could not set the userfield. This is the first problem about CDR. The second problem is the lenght of the message is like 40 seconds. Even the callees listen till the end of the message in the CDR it is shown like 10 seconds or something. The billsec is either 1 or 2. I don’t get it.

Isn’t there any workaround? Or anything you suggest to relate the CDR to my applications database?

Setting userfield after the call ? I doubt it’s possible,
Specially not in that way, just before hangup. Meyby in some deadagi script or something.
Yor example should not work at all.

You can run AGI, get all variables to dialplan, then run Dial.

Well i tried to set the userfield in the agi script but it did not work either. What i did was something like this :

#!/usr/bin/php -q

<?php set_time_limit(0); require('phpagi.php'); $starttime = time(); $agi = new AGI(); //this creates a new AGI object with all the agi vars read in. $agi->answer(); $campaignid = $argv[1]; //Campaign Id ... $agi->exec('Set','CDR(userfield)=Value'); Any suggestions about where i can set this field?

1st step. Can You set any channel variable from php script ?
(based on Your example):
$agi->exec(‘Set’, ‘MYVAR=myvar1’)
then in asterisk
exten => s,1,agi(…)
exten => s,n,set(CDR(userfield)=${MYVAR})

I had some problems searchinf database for values and playback specified sounds inside bash script.
In the end, script only set up 5 channel variables.