[BUG]: CDR(userfield) cannot be populated correctly

Hi
im using func-apply-sipheaders dislplan in order to set CDR(userfield) in a call from Queeu to extension

but for some reason when I set it to 123456 in database ; appears

[2024-08-22 10:48:55] VERBOSE[50335][C-0000000e] pbx.c: Executing [s@func-apply-sipheaders:5] Set(“PJSIP/225-00000015”, “CDR(userfield)=123456”) in new stack

I tried
exten => s,n,Set(CDR(userfield)=)
exten => s,n,Set(CDR(userfield)=123456)

but ; still there

please advice

here is verbose


but in CDR it is ;123456

maybe im doing something wrong
but what I want

1- add X-Custom Header to call from PBX to Extension from func-apply-sipheaders dialplan
this one is working
2- add CDR(userfield) so I can identify based on userfield all calls that belongs to original incoming call this one is NOT working

[func-apply-sipheaders]
include => func-apply-sipheaders-custom
exten => s,1,Noop(Applying SIP Headers to channel ${CHANNEL})
exten => s,n,Set(TECH=${CUT(CHANNEL,/,1)})
exten => s,n,Set(SIPHEADERKEYS=${HASHKEYS(SIPHEADERS)})
exten => s,n,While($["${SET(sipkey=${SHIFT(SIPHEADERKEYS)})}" != ""])
exten => s,n,Set(sipheader=${HASH(SIPHEADERS,${sipkey})})
exten => s,n,ExecIf($["${sipheader}" = "unset" & "${TECH}" = "SIP"]?SIPRemoveHeader(${sipkey}:))
exten => s,n,ExecIf($["${sipheader}" = "unset" & "${TECH}" = "PJSIP"]?Set(PJSIP_HEADER(remove,${sipkey})=))
exten => s,n,ExecIf($["${sipheader}" != "unset" & "${sipkey}" = "Alert-Info" & ${REGEX("^<[^>]*>" ${sipheader})} != 1 & ${REGEX("\;info=" ${sipheader})} != 1]?Set(sipheader=<http://127.0.0.1>\;info=${sipheader}))
exten => s,n,ExecIf($["${sipheader}" != "unset" & "${sipkey}" = "Alert-Info" & ${REGEX("^<[^>]*>" ${sipheader})} != 1]?Set(sipheader=<http://127.0.0.1>${sipheader}))
exten => s,n,ExecIf($["${TECH}" = "SIP" & "${sipheader}" != "unset"]?SIPAddHeader(${sipkey}:${sipheader}))
exten => s,n,ExecIf($["${TECH}" = "PJSIP" & "${sipheader}" != "unset"]?Set(PJSIP_HEADER(add,${sipkey})=${sipheader}))
exten => s,n,EndWhile
exten => s,n,Set(PJSIP_HEADER(add,X-Custom)=${CALLIDVAR})
exten => s,n,NoOp(CDR userfield before setting: ${CDR(userfield)})
exten => s,n,Set(CDR(userfield)=${CALLIDVAR})
exten => s,n,NoOp(CDR userfield after setting: ${CDR(userfield)})
exten => s,n,Return()

;--== end of [func-apply-sipheaders] ==--;

[ext-queues]
exten => h,1,NoOp(==End Call==)
same => n,NoOp(CDR userfield:${CDR(userfield)})
same => n,Macro(hangupcall,)


[from-queue-exten-only]
exten => h,1,NoOp(==End Call==)
same => n,NoOp(CDR userfield:${CDR(userfield)})
same => n,Macro(hangupcall,)
-- Executing [s@func-apply-sipheaders:13] Set("PJSIP/222-00000027", "PJSIP_HEADER(add,X-Custom)=1724327461.119") in new stack
    -- Executing [s@func-apply-sipheaders:14] NoOp("PJSIP/222-00000027", "CDR userfield before setting: ") in new stack
    -- Executing [s@func-apply-sipheaders:15] Set("PJSIP/222-00000027", "CDR(userfield)=1724327461.119") in new stack
    -- Executing [s@func-apply-sipheaders:16] NoOp("PJSIP/222-00000027", "CDR userfield after setting: 1724327461.119") in new stack
    -- Executing [s@func-apply-sipheaders:17] Return("PJSIP/222-00000027", "") in new stack
.........................
-- Executing [h@from-queue-exten-only:1] NoOp("Local/222@from-queue-00000020;2", "==End Call==") in new stack
    -- Executing [h@from-queue-exten-only:2] NoOp("Local/222@from-queue-00000020;2", "CDR userfield:") in new stack
    -- Executing [h@from-queue-exten-only:3] Macro("Local/222@from-queue-00000020;2", "hangupcall,") in new stack
    -- Executing [s@macro-hangupcall:1] GotoIf("Local/222@from-queue-00000020;2", "1?theend") in new stack
    -- Goto (macro-hangupcall,s,3)
    -- Executing [s@macro-hangupcall:3] ExecIf("Local/222@from-queue-00000020;2", "0?Set(CDR(recordingfile)=)") in new stack
    -- Executing [s@macro-hangupcall:4] Hangup("Local/222@from-queue-00000020;2", "") in new stack
.....................................
 -- Executing [h@ext-queues:1] NoOp("SIP/numbergroup-00000011", "==End Call==") in new stack
    -- Executing [h@ext-queues:2] NoOp("SIP/numbergroup-00000011", "CDR userfield:1724327461.119") in new stack
    -- Executing [h@ext-queues:3] Macro("SIP/numbergroup-00000011", "hangupcall,") in new stack
    -- Executing [s@macro-hangupcall:1] GotoIf("SIP/numbergroup-00000011", "1?theend") in new stack
    -- Goto (macro-hangupcall,s,3)
    -- Executing [s@macro-hangupcall:3] ExecIf("SIP/numbergroup-00000011", "0?Set(CDR(recordingfile)=)") in new stack
    -- Executing [s@macro-hangupcall:4] Hangup("SIP/numbergroup-00000011", "") in new stack


as your advice i tried on a hangup but as U can see no luck

image

And for anyone who stumbles upon this, it was also filed on Github: [bug]: CDR(userfield) prefix ; added for some reason · Issue #388 · FreePBX/issue-tracker · GitHub

1 Like

yes it was me

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