asterisk 11.1
Documentation in cdr.conf for endbeforehexten reads:
Normally, CDR's are not closed out until after all extensions are 
finished executing.  By enabling this option, the CDR will be ended 
before executing the "h" extension and hangup handlers so that CDR 
values such as "end" and "billsec" may be retrieved inside
of of this
extension.
I have explicitly set endbeforehexten=no, yet the CDR records are being 
written as soon as the operator hangs up the call (this is in a queue 
situation).  If I insert Wait() in the dialplan where the comments "note 
CDR is already written by this point" are, I can query the database and 
see the CDR record.
My dialplan excerpt is below.  Is there a way to force the CDR to not be 
written until the end of my dialplan logic?  In particular, I want to be 
able to store the results of the post call survey in the CDR.  I'm using 
cdr_adaptive_odbc.
[queues]
; this runs on the caller's channel
exten =>sales,1,Verbose(2,${CALLERID(all)} entering the sales queue)
   same =>n,Answer()
   same =>n(asksurvey),Read(MMSURVEY,custom/survey-ask,1,,,5)
   same =>n,MixMonitor(${CHANNEL(uniqueid)}.wav,b)
   same =>n,Set(CDR(salesqueue_entered)=1)
   same =>n,Queue(sales,tc,,,,,,sub-QueueConnected)
   same =>n,GotoIf($["${QUEUESTATUS}" =
"CONTINUE"]?checksurvey) ; only
go to the survey if we were connected to a call
   same =>n,Playback(custom/queue-sales-no-operators)
   same =>n,Hangup()
   same =>n(checksurvey),GotoIf($["${MMSURVEY}" =
"1"]?survey,s,1)
   same =>n,Hangup()
exten =>h,1,NoOp(When a sales queue call is hung up)
   ; note CDR is already written by this point
   same =>n,StopMixMonitor()
   same =>n,Hangup()
[survey]
exten =>s,1,NoOp(Take the survey)
   ; note CDR is already written by this point
   same =>n(q1),Read(MMSURVEYQ1,custom/survey-q1,1,,,5)
   ... more survey here
-- 
Mitch