Persistent Variables

My understanding is that persistent variables declared like this
SET(__CUSTDATA=some value) should remain in every leg of the channel moving forward and be accessible like this ${CUSTDATA}

This works as expected for 90% of the cases and in remaining 10 I see the variable is set in the originating dialplan but it’s value is not transferred to the next channel. I am trying to understand why this happens.

While on this topic, I wanted to check if CDR variables could be used to maintain data across all legs of the call without employing CID vars.
All I want is to set a value in the original leg of the call and maintain it

It’s called Variable Inheritance

https://wiki.asterisk.org/wiki/display/AST/Variable+Inheritance

Are you doing anything ‘odd’ with your channels, Parking, Stealing, Redirecting, Bridging on those 10% of the calls where it’s not working as expected?

You could try storing and retrieving data in ${CDR(userfield)}

Looks like things do get done to it, oddly target channel seems to have original channels data when request is in small number of cases. I think its because things happen very quickly. In these cases inherited variable is empty.

I was able to find the solution, by checking if channel has original channel data and use that instead.

1 Like