SIP_CAUSE in originate call

Hi all

I’m using AMI Originate s function to make one call. Originate call this local context:

[from-local] exten => 3000,1,Set(REDIRECTING_CALLER_SEND_MACRO=redirect-caller) same => n,Set(_MASTERCHANNEL=${CHANNEL}) same => n,Dial(${DEST}) same => n,Set(SIPCAUSE=${MASTER_CHANNEL(HASH(SIP_CAUSE,${CDR(dstchannel)}))}) same => n,Set(SIPCODE=${CUT(SIPCAUSE," ",2)})

When the call fails, I do get the SIPCODE var filled. I need to use this variable in the h extension in the final context, but I can’t find a way to recover it from there.

exten => h,1,System(curl -G -d 'id=${ID}&os=${RESULT}&cs=${HANGUPCAUSE}&rs=${REASON}&rd=${SHARED(REDIRECT,${CHANNEL})}&sc=${MASTER_CHANNEL(SIPCODE)}&bs=${CDR(billsec)}&ui=${USERINPUT}' --data-urlencode 'dt=${STRFTIME(${EPOCH},GMT-5,%F %T)}' --data-urlencode 'rf=${MIXMONITOR_FILENAME}' ${URL})

Here is the output:

Verbosity is at least 3 -- Executing [3000@from-local:1] Set("Local/3000@from-local-00000019;2", "REDIRECTING_CALLER_SEND_MACRO=redirect-caller") in new stack -- Executing [3000@from-local:2] Set("Local/3000@from-local-00000019;2", "_MASTERCHANNEL=Local/3000@from-local-00000019;2") in new stack -- Executing [3000@from-local:5] Dial("Local/3000@from-local-00000019;2", "SIP/emelo") in new stack == Using SIP RTP CoS mark 5 -- Called SIP/emelo -- SIP/emelo-00000019 is ringing -- Got SIP response 603 "Decline" back from 192.168.1.5:5060 -- SIP/emelo-00000019 is busy == Everyone is busy/congested at this time (1:1/0/0) -- Executing [3000@from-local:6] Set("Local/3000@from-local-00000019;2", "SIPCAUSE=SIP 603 Decline") in new stack -- Executing [3000@from-local:7] Set("Local/3000@from-local-00000019;2", "SIPCODE=603") in new stack -- Auto fallthrough, channel 'Local/3000@from-local-00000019;2' status is 'BUSY' -- Executing [failed@tts:1] Set("OutgoingSpoolFailed", "RESULT=FAILED") in new stack -- Auto fallthrough, channel 'OutgoingSpoolFailed' status is 'UNKNOWN' -- Executing [h@tts:1] System("OutgoingSpoolFailed", "curl -G -d 'id=6f985e72-32ef-498f-873c-bbb1fcde7667&os=FAILED&cs=0&rs=5&rd=&sc=&bs=0&ui=' --data-urlencode 'dt=2014-02-28 16:20:16' --data-urlencode 'rf=' http://192.168.1.5:8080/voice/conf/") in new stack

Any ideas ?