Setting custom channel variable in LUA dialplan

Hello,

I’m trying to create a custom channel variable in a LUA dialplan.

So I set the channel variable inside of the default context:
channel[“newVar”] = “value”

and in my hangup function, I try to call back that variable:
app.verbose("CHANNEL VARIABLE TEST: "…channel.newVar:get())

This results in the following error:
ERROR[26777][C-00000002]: pbx_lua.c:1456 exec: Error executing lua extension:
[string “extensions.lua”]:227: attempt to concatenate a nil value

However, if I set the channel variable inside of the hangup function itself using the same method, the variable is correctly collected and printed.

I’ve also attempted to set the channel variable with the following two methods, with the same results:
alternate method #1:
channel.newVar = “value”
alternate method #2:
var = channel.newVar
var:set(“value”)

I’ve uploaded my current dialplan here:
http://petervanhaaften.net/files/extensions_current_feb23_1.lua

Can anyone sugggest a work around for this problem? Many thanks in advance!

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