C.6. CDR()

CDR(field)
Reads or sets CDR[82] fields. The field is one of the following (only reading is possible unless otherwise noted):
clid
Caller ID
src
The source number (caller ID number)
dst
The call destination
dcontext
Destination context
channel
Channel name
dstchannel
Destination channel, if applicable
lastapp
The last executed application
lastdata
The arguments to the last executed application
start
Time the call started
answer
Time the call was answered
end
Time the call ended
duration
Duration of the call in seconds
billsec
Duration of the call since the call was answered (in other words, the billable duration) in seconds
disposition
Status of the call: ANSWERED, NO ANSWER, BUSY or FAILED
amaflags
The AMA[83] flags. Possible flags are DEFAULT, BILLING, DOCUMENTATION and OMIT. (Sometimes BILLING and OMIT are replaced by BILL and IGNORE, perhaps depending on the Asterisk version.)
accountcode
The alphanumeric ID of the billing account, maximum 20 characters. May be set as well as read
uniqueid
The unique ID of the channel (maximum 32 characters)
userfield
A user field for storing arbitrary information (maximum 255 characters). May be set as well as read
; Set foo to the duration of the call:
exten => 123,1,Set(foo=${CDR(duration)})

; Set the user field to "my information":
exten => 123,1,Set(CDR(userfield)=my information)

Note

Internal help for this application in Asterisk 1.4:
  -= Info about function 'CDR' =- 

[Syntax]
  Here is a list of all the available cdr field names:
    clid          lastdata       disposition
    src           start          amaflags
    dst           answer         accountcode
    dcontext      end            uniqueid
    dstchannel    duration       userfield
    lastapp       billsec        channel
  All of the above variables are read-only, except for accountcode,
  userfield, and amaflags. You may, however,  supply
  a name not on the above list, and create your own
  variable, whose value can be changed with this function,
  and this variable will be stored on the cdr.
   raw values for disposition:
       1 = NO ANSWER
       2 = BUSY
       3 = FAILED
       4 = ANSWERED
    raw values for amaflags:
       1 = OMIT
       2 = BILLING
       3 = DOCUMENTATION


[Synopsis]
Gets or sets a CDR variable

[Description]
Options:
  'r' searches the entire stack of CDRs on the channel
  'u' retrieves the raw, unprocessed value
  For example, 'start', 'answer', and 'end' will be retrieved as epoch
  values, when the 'u' option is passed, but formatted as YYYY-MM-DD HH:MM:SS
  otherwise.  Similarly, disposition and amaflags will return their raw
  integral values.
diff output to internal help in Asterisk 1.2:
5,26c5
<   Here is a list of all the available cdr field names:
<     clid          lastdata       disposition
<     src           start          amaflags
<     dst           answer         accountcode
<     dcontext      end            uniqueid
<     dstchannel    duration       userfield
<     lastapp       billsec        channel
<   All of the above variables are read-only, except for accountcode,
<   userfield, and amaflags. You may, however,  supply
<   a name not on the above list, and create your own
<   variable, whose value can be changed with this function,
<   and this variable will be stored on the cdr.
<    raw values for disposition:
<        1 = NO ANSWER
<        2 = BUSY
<        3 = FAILED
<        4 = ANSWERED
<     raw values for amaflags:
<        1 = OMIT
<        2 = BILLING
<        3 = DOCUMENTATION
< 
---
> CDR(<name>[|options])
32,38c11
< Options:
<   'r' searches the entire stack of CDRs on the channel
<   'u' retrieves the raw, unprocessed value
<   For example, 'start', 'answer', and 'end' will be retrieved as epoch
<   values, when the 'u' option is passed, but formatted as YYYY-MM-DD HH:MM:SS
<   otherwise.  Similarly, disposition and amaflags will return their raw
<   integral values.
---
> Option 'r' searches the entire stack of CDRs on the channel


Call Data Record
Automated Message Accounting