How to get SIP_CAUSE in out going calls


I want to get the SIP Cause text from the SIP packet. Asterisk do provide us the SIP_CAUSE variable, but I am unable to use it. Rite now, I am trying to get the cause in my dialplan as

exten => failed,n,Set(sip_cause=${HASH(SIP_CAUSE,${CHANNEL})});

in failed extension.

Also I have enabled it in the sip.conf as


I am using Asterisk ver 1.8.11, and not getting the SIP CAUSE.

Any help will be appreciated. If there is any other way to get the SIP cause string/code, plz let me know.

Try with ${CDR(dstchannel)} and set the “SET” after the dial command.