GotoIf() not working as expected


I’m having a problem that seems pretty straight forward but I cannot seem to get it to work.

Trying to get a call to mysql when a user presses “1”

exten => request,n,GotoIf($["${USECALLERID}" = “1”]?StoreNum)

To go to

exten => request,n(StoreNum),MYSQL(Query r ${connid} INSERT INTO callers set uniqueid=’${UNIQUEID}’, callback=1,callbacknum=’${CALLBACKNUM}’,queueid=‘930’,queuename=‘queuename’, attempts=‘0’, lastattempt=NOW(), namefile=‘TEST’)

I can see in the logs that the call in the GoToIf() is going to the correct place and outputting the correct mysql call but nothing ends up in the database. There is nothing useful in the mysql logs. All other mysql calls are working and if I don’t call StoreNum directly the INSERT works fine. Has anyone seen this behavior before?

Thanks for your time,

Man It’s been a while since I used app_mysql, have you tried echoing back the result going into the ‘r’ variable?

Why are you using app_mysql instead of func_odbc?

It’s an inherited system and I was just using what the dial plan already had. I can echo back the sql statement and it looks ok and all the vars are there. I can run the the echoed call back on the mysql cli and the insert works. Very curious why the StoreNum function works but not when called directly. Wondering if I am missing something as I put in a

exten => request,n,NoOp(“MADE IT TO INSERT”)

directly before the mysql call and can see that in the logs. Strange also that isn’t throwing any errors.


What about if you add a:

exten => request,n,NoOp(Result: ${r})

after your StoreNum label?

Thanks for the idea. The result is blank. It seems I was skipping setting up the ${connid} var when calling the label.

Thank you very much for taking the time to help out. I was almost out of hair to pull out.


1 Like