Get the answer time in call file

hi, i use call file to setup calls.Here is the call file examples:
Channel:SIP/13012345678@TG1-VD1
Context:callout
Extension: _X.
Callerid:<031187632>
Account:aliese
MaxRetries:0
RetryTime:300
WaitTime:45
Archive:yes
Setvar:dst=18098786765

when 13012345678 answers, go to callout context. and the context have to dial dst.
channel.exec(“Dial”, dialPrefix + “/” + call.getPrefixedDst() + call.getSipTrunk() +“,300,U(custom-dial-handler^s^1))”);
channel.exec(“NoOp”,“Answered at:” + channel.getVariable(“ANSWERED_TIME”));
channel.exec(“NoOp”,“Answered at:” + channel.getVariable(“__ANSWERED_TIME”));

here is the
[custom-dial-handler]
exten => s,1,Set(ring_start=${EPOCH})
same => n,Set(CDR(answeredtime)=${STRFTIME(${EPOCH},%Y-%m-%d %H:%M:%S)})
same => n,Set(__ANSWERED_TIME=${STRFTIME(${EPOCH},%Y-%m-%d %H:%M:%S)})
same => n,Return()

but after return ,i cann’t get the __ANSWERED_TIME,here is the log:

    -- SIP/TG1-VD1-00000075 Internal Gosub(custom-dial-handler,s,1(s,1)) start
    -- Executing [s@custom-dial-handler:1] Set("SIP/SS1-VD1-00000075", "ring_start=1733844014") in new stack
    -- Executing [s@custom-dial-handler:2] NoOp("SIP/SS1-VD1-00000075", "helll,") in new stack
    -- Executing [s@custom-dial-handler:3] Set("SIP/SS1-VD1-00000075", "CDR(answeredtime)=2024-12-10 23:20:14") in new stack
    -- Executing [s@custom-dial-handler:4] Set("SIP/SS1-VD1-00000075", "ANSWERED_TIME=2024-12-10 23:20:14") in new stack
    -- Executing [s@custom-dial-handler:5] Set("SIP/SS1-VD1-00000075", "__ANSWERED_TIME=2024-12-10 23:20:14") in new stack
    -- Executing [s@custom-dial-handler:6] Return("SIP/SS1-VD1-00000075", "") in new stack
  == Spawn extension (from-sip, , 1) exited non-zero on 'SIP/SS1-VD1-00000075'
    -- SIP/SS1-VD1-00000075 Internal Gosub(custom-dial-handler,s,1(s,1)) complete GOSUB_RETVAL=
    -- Channel SIP/SS1-VD1-00000075 joined 'simple_bridge' basic-bridge <2184dc23-7c3d-4bd5-ae12-c62f894d045f>
    -- Channel SIP/SS1-VD1-00000074 joined 'simple_bridge' basic-bridge <2184dc23-7c3d-4bd5-ae12-c62f894d045f>
       > 0x7f85b8016cf0 -- Strict RTP learning complete - Locking on source address 172.22.11.12:16864
    -- Channel SIP/SS1-VD1-00000075 left 'simple_bridge' basic-bridge <2184dc23-7c3d-4bd5-ae12-c62f894d045f>
    -- Channel SIP/SS1-VD1-00000074 left 'simple_bridge' basic-bridge <2184dc23-7c3d-4bd5-ae12-c62f894d045f>
    -- AGI Script Executing Application: (NoOp) Options: (Answered at:null)
    -- AGI Script Executing Application: (NoOp) Options: (Answered at:null)

so my question is dial with U don’t pass the channel variables ? and how can i get the answer time?

The U subroutine is run on the called channel. Variables don’t propagate back towards the calling channel, only forwards towards the called one. You will have to explicitly use SHARED variables to set one on the calling channel, from that subroutine.

Why can’t you read it from the CDR?

Note that chan_sip is no longer supported.

Also, I believe CDR(answertime) is read-only, and I don’t understand in what way the use of call files is relevant.

If you really have _X. as an extension in the call file, I can’t see its working. You won’t be able to match the _, as a dialplan _ starts a pattern match. If the dialplan actually has _X. , the _will set in pattern mode and the X will not match the _ or the X, as it only matches decimal digits.

change to pjsip is the same.
and here is the dump infomation:

2024-12-10 23:44:36,042-[AJ DaemonPool-1.3] INFO SYSOUT - ==== CDR Fields ====
2024-12-10 23:44:36,060-[AJ DaemonPool-1.3] INFO SYSOUT - CDR(accountcode) = aliese
2024-12-10 23:44:36,101-[AJ DaemonPool-1.3] INFO SYSOUT - CDR(src) = 031187632
2024-12-10 23:44:36,134-[AJ DaemonPool-1.3] INFO SYSOUT - CDR(dst) = _X.
2024-12-10 23:44:36,156-[AJ DaemonPool-1.3] INFO SYSOUT - CDR(dcontext) = callout
2024-12-10 23:44:36,173-[AJ DaemonPool-1.3] INFO SYSOUT - CDR(channel) = SIP/SS1-VD1-00000076
2024-12-10 23:44:36,196-[AJ DaemonPool-1.3] INFO SYSOUT - CDR(dstchannel) = PJSIP/SS1-VD1-00057172
2024-12-10 23:44:36,211-[AJ DaemonPool-1.3] INFO SYSOUT - CDR(lastapp) = Dial
2024-12-10 23:44:36,227-[AJ DaemonPool-1.3] INFO SYSOUT - CDR(lastdata) = PJSIP/18098786765@SS1-VD1,300,U(custom-dial-handler^s^1))
2024-12-10 23:44:36,244-[AJ DaemonPool-1.3] INFO SYSOUT - CDR(start) = 2024-12-10 23:43:56
2024-12-10 23:44:36,260-[AJ DaemonPool-1.3] INFO SYSOUT - CDR(answer) = 2024-12-10 23:44:25
2024-12-10 23:44:36,278-[AJ DaemonPool-1.3] INFO SYSOUT - CDR(end) = 2024-12-10 23:44:34
2024-12-10 23:44:36,315-[AJ DaemonPool-1.3] INFO SYSOUT - CDR(duration) = 38
2024-12-10 23:44:36,343-[AJ DaemonPool-1.3] INFO SYSOUT - CDR(billsec) = 9
2024-12-10 23:44:36,359-[AJ DaemonPool-1.3] INFO SYSOUT - CDR(disposition) = ANSWERED
2024-12-10 23:44:36,376-[AJ DaemonPool-1.3] INFO SYSOUT - CDR(amaflags) = DOCUMENTATION
2024-12-10 23:44:36,401-[AJ DaemonPool-1.3] INFO SYSOUT - CDR(uniqueid) = 1733845436.531580
2024-12-10 23:44:36,417-[AJ DaemonPool-1.3] INFO SYSOUT - **CDR(answeredtime) =** 
2024-12-10 23:44:36,418-[AJ DaemonPool-1.3] INFO SYSOUT - ==== Channel Variables ====
2024-12-10 23:44:36,438-[AJ DaemonPool-1.3] INFO SYSOUT - CALLERID(num) = 031187632
2024-12-10 23:44:36,455-[AJ DaemonPool-1.3] INFO SYSOUT - CALLERID(name) = 
2024-12-10 23:44:36,472-[AJ DaemonPool-1.3] INFO SYSOUT - DIALSTATUS = ANSWER
2024-12-10 23:44:36,503-[AJ DaemonPool-1.3] INFO SYSOUT - HANGUPCAUSE = 16
2024-12-10 23:44:36,520-[AJ DaemonPool-1.3] INFO SYSOUT - UNIQUEID = 1733845436.531580
2024-12-10 23:44:36,543-[AJ DaemonPool-1.3] INFO SYSOUT - EXTEN = _X.
2024-12-10 23:44:36,559-[AJ DaemonPool-1.3] INFO SYSOUT - CONTEXT = callout
2024-12-10 23:44:36,584-[AJ DaemonPool-1.3] INFO SYSOUT - PRIORITY = 1
2024-12-10 23:44:36,605-[AJ DaemonPool-1.3] INFO SYSOUT - CHANNEL = SIP/SS1-VD1-00000076
2024-12-10 23:44:36,626-[AJ DaemonPool-1.3] INFO SYSOUT - DIALEDTIME = 38
2024-12-10 23:44:36,670-[AJ DaemonPool-1.3] INFO SYSOUT - ANSWEREDTIME = 9
2024-12-10 23:44:36,708-[AJ DaemonPool-1.3] INFO SYSOUT - BRIDGEPEER = null
2024-12-10 23:44:36,724-[AJ DaemonPool-1.3] INFO SYSOUT - RINGTIME = 0
2024-12-10 23:44:36,741-[AJ DaemonPool-1.3] INFO SYSOUT - BRIDGEDTIME = null
2024-12-10 23:44:36,788-[AJ DaemonPool-1.3] INFO SYSOUT - **ANSWERED_TIME** = null

CDR(answeredtime)

is there any way to get answer_time in called channel?

is there any other way to get answer time?