Summary:ASTERISK-17154: CDR fileds not being written from "h" extension or after "Dial" command completes.
Reporter:Bryant Zimmerman (zktech)Labels:
Date Opened:2010-12-23 10:05:16.000-0600Date Closed:2011-06-07 14:05:28
Versions:Frequency of
Description:We have dial macros that handle our dialing. we use both the "g" and "e" options in the Dial command so that we can store addtional data after the call is hung up. The issue is that when a call is hung up and we do a Set(CDR(field)=value) the value is not stored. Any vlaue set before the dial is made is stored correctly but nothing after the dial. We have confirmed that endbeforehexten=no but this does not seem to have any bearing on the issue. It appears that the cdr is written before any updates can be made using the "g" or "e" process options. I have included a small snip of code in the Additonal Info field here.  Tested on and 1.8/SVN


My "h" extension is in the same context as my Dial commands. Here is a cut back version of the code.
The cause_code value is never stored in the mysql databae even when set in the "h" extension or the
when set in "rc-ANSWER' OR "doDialStd"

exten => s,1,Macro(${ARG1})
exten => s,n,Set(CALLERID(name)=${siteDefaultCIDName})
exten => s,n,Set(CALLERID(number)=${siteDefaultCIDNumber})
exten => s,n,SipAddHeader(X-interNetGR-linetype:${gbl_ibclinetype})
exten => s,n,SipAddHeader(X-interNetGR-actlineid:${gbl_actlineid})
exten => s,n,Set(GROUP()=${siteGrpLineCount})
exten => s,n,Set(c_DialArg=${ARG2})
exten => s,n,Set(c_DialExten=${MACRO_EXTEN})
exten => s,n,GoSub(DoLineCountCheck,1)
exten => s,n,GotoIf($[${siteOverLineCount}=1]?OverLineCount,1)
exten => s,n,GosubIf($["${c_DialExten}"="${siteDirSer}"]?OverLineCount,1)
exten => s,n,GosubIf($["${c_DialExten}"="411"]?nofeature,1)
exten => s,n,GosubIf($["${siteUseE164}"="1"]?doDialE164,1:doDialStd,1)
exten => s,n,Goto(rc-${DIALSTATUS},1)
exten => s,n,Busy(60)
exten => s,n,Hangup()

exten => h,1,NoOp(Cause Code = ${HANGUPCAUSE})
exten => h,n,Set(CDR(cause_code)=${HANGUPCAUSE})
exten => h,n,Goto(rc-${DIALSTATUS},1)

exten => doDialStd,1,NoOp(Calling Using No E164)
exten => doDialStd,n,Macro(OBD-CheckOutboundNumber,${c_DialArg}${c_DialExten})
exten => doDialStd,n,Dial(${siteDefaultOutboundTrunk}/${c_DialArg}${c_DialExten},120,ge${siteDialOptionsPublic})
exten => doDialStd,n,Set(CDR(cause_code)=${HANGUPCAUSE})
exten => doDialStd,n,Return

exten => rc-ANSWER,1,NoOp(Do Return ANSWER)
exten => rc-ANSWER,n,Set(CDR(cause_code)=${HANGUPCAUSE})
exten => rc-ANSWER,n,Hangup()

exten => rc-BUSY,1,NoOp(Do Return BUSY)
exten => rc-BUSY,n,Busy()
exten => rc-BUSY,n,Hangup()

exten => rc-NOANSWER,1,NoOp(Do Return NOANSWER)
exten => rc-NOANSWER,n,NoOp(Cause Code = ${HANGUPCAUSE})
exten => rc-NOANSWER,n,Hangup()
Comments:By: David Woolley (davidw) 2011-01-04 09:40:14.000-0600

I think this is a "feature", rather than a bug.  The bridge and channel CDRs get swapped in the "h" extension code and swapped back afterwards, or something similar.  We worked round this sort of thing by using ResetCDR to force the CDR out.

Also, I seem to remember this question on the Asterisk Forum.  If it was, you should include a link, so that people can see the full discussion.