GotoIf application doesn't work properly

I’m trying to make a simple dnd toggle by using GotoIf function that will change a value on database key. I’ve made a database with family key value = dnd 100 d and my extension is 100
if the value is “d” then set it to “a” and vice versa. Here’s my dialplan :

exten => _*78,1,GotoIf("${DB(dnd/${CALLERID(num)}}" = "d"]?activate:deactivate) exten => _*78,n(activate),Set(DB(dnd/${CALLERID(num)})=a) exten => _*78,n,Playback(activated) exten => _*78,n,Hangup() exten => _*78,n(deactivate),Set(DB(dnd/${CALLERID(num)})=d) exten => _*78,n,Playback(de-activated) exten => _*78,n,Hangup()

the problem is :
the first time i call *78, the value will be changed from “d” to "a"
but when i call *78 for the second time, the value won’t change to “d”.
and i end up getting this error

WARNING[2068][C-0000000d]: pbx.c:4040 func_args: Can't find trailing parenthesis for function 'DB(dnd/100'?

does anybody know which parenthesis should been added/changed to the dialplan?
i’m pretty sure i wrote the parenthesises in the dialplan correctly though :confused:
or if you have a better efficient dialplan for turning on and off application please let me know :smile:
please help this noob :astonished:

You are missing the [

thank you Navaismo! but i still don’t get the dialplan plan work correctly though. :frowning:
here’s my new dialplan, i ran it without getting errors… but the same problem still exist.

exten => _*78,1,GotoIf(["${DB(dnd/${CALLERID(num)})}" = "d"]?activate:deactivate)
exten => _*78,n(activate),Set(DB(dnd/${CALLERID(num)})=a)
exten => _*78,n,Playback(activated)
exten => _*78,n,Hangup()
exten => _*78,n(deactivate),Set(DB(dnd/${CALLERID(num)})=d)
exten => _*78,n,Playback(de-activated)
exten => _*78,n,Hangup()

the problem is :
the first time i call *78, the value will be changed from “d” to "a"
but when i call *78 for the second time, the value won’t change to “d”.
does anybody know how to resolve this? i’m still trying to figure it out.

Show us the complete cli output, and the result of database show before the Call.

I’ve finally got it work by using ISNULL application…
i still really don’t know what was wrong with the simple GotoIf in my previous dialplan though.

i changed the “a” and “d” value in my database into “” (null) and “1”

This is my new dialplan :

exten => _*78,1,Set(var=${DB(dnd/${CALLERID(num)})}) exten => _*78,n,GotoIf($[${ISNULL(${var})}]?activate:deactivate) exten => _*78,n(activate),Set(DB(dnd/${CALLERID(num)})=1) exten => _*78,n,Playback(activated) exten => _*78,n,Hangup() exten => _*78,n(deactivate),Set(DB(dnd/${CALLERID(num)})=) exten => _*78,n,Playback(de-activated) exten => _*78,n,Hangup()

Problem solved… :smiley: Thanks for the assist Navaismo!

Well in your earlier example you were missing $ in GotoIf application otherwise it should have worked. It has to be,
exten => _*78,1,GotoIf($["${DB(dnd/${CALLERID(num)})}" = “d”]?activate:deactivate)

And not

exten => _*78,1,GotoIf(["${DB(dnd/${CALLERID(num)})}" = “d”]?activate:deactivate)

–Satish Barot