How to know who hangup?


Platform: Debian Squeeze 64
Asterisk: 11.2-cert1

I need to keep a record in the CDR who hang up the call.

I use flag g in Dial CMD or h exten but not work.
My Dialplan example:

[code]exten => 111,1,Noop(Inbound call)
exten => 111,n,Dial(SIP/111,g)
exten => 111,n,Set(CDR(term)=CALLED) ;**
exten => 111,n,Noop(Hangup Called)

exten => h,1,Noop(Hangup caller)
exten => h,n,Set(CDR(term)=CALLER) ;**[/code]

[color=#FF0000]exten => 111,n,Set(CDR(term)=CALLED) ;**
exten => h,n,Set(CDR(term)=CALLER) ;**
This lines execute but not record in the CDR.

I know can be done using some agi or some other mechanism but didn’t like add complexity to my dialplan.

I thought this was an error on asterisk but I suggest that it is not.

Sorry for my bad english :frowning:

Asterisk does some swapping of CDRs. I think you may need to force the CDR out with ResetCDR.

Excuse me, but do not understand that using ResetCDR.
What it’s logic use ResetCDR?

ResetCDR with the w option writes out the CDR you are currently looking at, so using it immediately after setting custom field should ensure the modified CDR is written out.

On the other hand, note that CDRs have problems, and complex applications should use call event logging.