CDR function in midle of call


The CDR function confuses me , I use this dial plan for transferred calls (blind PBX transfer I mean ):

same => n,Noop(TRANSFERDEBUG: {DEVICE_STATE(SIP/{EXTTOCALL})} – {CALLERID(num)} -- {FROMEXTEN} – {EXTTOCALL} -- {CHANNEL(channeltype)} – ${CDR(billsec)} )

same => n,Set(BILLIKHARE=${CDR(billsec)})

And resault on CLI is something like this :

– Executing [2025@from-internal-xfer-temp:2] NoOp(“Local/1345@from-queue-000150fe;2”, "TRANSFERDEBUG: NOT_INUSE – 9902923400 – – 1345 – Local – 68 ") in new stack

– Executing [2025@from-internal-xfer-temp:3] Set(“Local/1345@from-queue-000150fe;2”, “BILLIKHARE=0”) in new stack

Why the Noop app can read ${CDR(billsec)} value ( 68 sec ), but the Set app can’t assign it?

billsec is not settable as it based on measured values.

As the wiki says:

All of the CDR field names are read-only, except for accountcode , userfield , and amaflags .

Yes I know , most of them are read-only but I don’t want to change them just access them . and still the question is why the noop can access and the set can’t.

I didn’t understand the question properly. The problem is I read the question, and not the context, and answered why Set could not assign that field, whereas the actual code is assigning BILLIKHARE, not the CDR function.

If the code has been cut and pasted accurately, this doesn’t make sense, as the dialplan interpreter has no idea which application will get called at the point where the variable is substituted, and the function evaluator only knows the channel. The function is definitely being substituted. If it weren’t matched, the result would be an empty string, not “0”.

The only thing I can think of that would cause this anomaly is if the code is being executed at a point when the value is changing. As such, I think it would be necessary to see priority 1, and also what caused the extension to start running in that context.

Please repost your dialplan snippet and console log in 'Preformatted tags'

I have this snippet:

; billsec
        same = n,                       wait(5)
        same = n,                       verbose(as CDR variable ${CDR(billsec)})
        same = n,                       set(BILLIKHARE=${CDR(billsec)})
        same = n,                       verbose(as my variable ${BILLIKHARE})
        same = n,                       hangup()

And it generates this console log:

    -- Executing [*@newline:6] Wait("SIP/poly-77a1-000001ca", "5") in new stack
       > 0x691a4468 -- Strict RTP learning complete - Locking on source address
    -- Executing [*@newline:7] Verbose("SIP/poly-77a1-000001ca", "as CDR variable 5") in new stack
as CDR variable 5
    -- Executing [*@newline:8] Set("SIP/poly-77a1-000001ca", "BILLIKHARE=5") in new stack
    -- Executing [*@newline:9] Verbose("SIP/poly-77a1-000001ca", "as my variable 5") in new stack
as my variable 5
    -- Executing [*@newline:10] Hangup("SIP/poly-77a1-000001ca", "") in new stack

Let me explain in detail

I use ${CDR(billsec)}) variable at end of the call in hangup extension and it works fine. so I decide to use it for logging in blind transferred calls in the context “from-internal-xfer-temp” calls transfered from a queue, here is loaded PBX dial plan :

CLI> dialplan show from-internal-xfer-temp

[ Context ‘from-internal-xfer-temp’ created by ‘pbx_config’ ]

‘_202[56]’ => 1. Set(__TRANSED=1) [pbx_config]

                  2. Noop(TRANSFERDEBUG: ${DEVICE_STATE(SIP/${EXTTOCALL})} -- ${CALLERID(num)} -- ${FROMEXTEN}  -- ${EXTTOCALL} -- ${CHANNEL(channeltype)}  -- ${CDR(billsec)} ) [pbx_config]

               3. Set(BILLIKHARE=${CDR(billsec)})            [pbx_config]

               4. gotoif($["${CHANNEL(channeltype)}" = "Local" & ${LEN(${EXTTOCALL})} > 1]?docheck:start) [pbx_config]

[docheck]      5. Set(hichi=${DB(IPPBX/TRANS ${EXTTOCALL} 1)}) [pbx_config]
[start]        6.Set(RING_TRANS(${UNIQUEID},${EXTTOCALL})=${CALLERID(num)},${EXTEN},${CDR(server_id)},${NODEST}) [pbx_config]

               7. Goto(from-internal,${EXTEN},1)             [pbx_config]

and Asterisk console log is here:

[2020-06-26 12:31:02] VERBOSE[28250][C-000256a2] pbx.c: Executing [2025@from-internal-xfer-temp:1] Set(“Local/1505@from-queue-00015dc0;2”, “__TRANSED=1”) in new stack

[2020-06-26 12:31:02] VERBOSE[28250][C-000256a2] pbx.c: Executing [2025@from-internal-xfer-temp:2] NoOp(“Local/1505@from-queue-00015dc0;2”, "TRANSFERDEBUG: NOT_INUSE – 9106987708 – – 1505 – Local – 57 ") in new stack

[2020-06-26 12:31:02] VERBOSE[28250][C-000256a2] pbx.c: Executing [2025@from-internal-xfer-temp:3] Set(“Local/1505@from-queue-00015dc0;2”, “BILLIKHARE=0”) in new stack

[2020-06-26 12:31:02] VERBOSE[28250][C-000256a2] pbx.c: Executing [2025@from-internal-xfer-temp:4] GotoIf(“Local/1505@from-queue-00015dc0;2”, “1?docheck:start”) in new stack

[2020-06-26 12:31:02] VERBOSE[28250][C-000256a2] pbx_builtins.c: Goto (from-internal-xfer-temp,2025,5)

As you can see, in the Noop {CDR(billsec)}) is 57 and in the next line BILLIKHARE={CDR(billsec)} it set to zero.

How does execution of from-internal-xfer-temp get started. This is not a context that has any special meaning to Asterisk. I suspect you are using a GUI, in which case you need to get support from the community for that GUI.

Yes, you 're right we use FreePBX. As I said “from-internal-xfer-temp” context used for transferred calls from queues by setting TRANSFER_CONTEXT global variable.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.