Dialplan issue with GotoIf

Please can someone take a look at this extract and debug for me!
I have tried as many ways as possible, with spaces around the =, quotes etc.

exten => 3146472,6,GotoIf($[${DB(blockedlist/"${CALLERID(number)}")} = 1]?blocked,s,1) exten => 3146472,7,GotoIf($[${DB(telemarketers/"${CALLERID(number)}")} = 1]?telemarketers,s,1)

I have tried to read up on voip-info.org but it still isn’t clear and usually I can manage to get it to do anything I want to. :cry:

The CLI currently reports
Oct 27 18:46:09 WARNING[4944]: ast_expr2.fl:183 ast_yyerror: ast_yyerror(): syntax error: syntax error, unexpected TOK_EQ, expecting TOK_MINUS or TOK_COMPL or TOK_LP or TOKEN; Input:
=1
^
Oct 27 18:46:09 WARNING[4944]: ast_expr2.fl:187 ast_yyerror: If you have questions, please refer to doc/README.variables in the asterisk source.
– Executing GotoIf(“SIP/8685445-f6322058”, “0?blocked|s|1”) in new stack
Oct 27 18:46:09 WARNING[4944]: ast_expr2.fl:183 ast_yyerror: ast_yyerror(): syntax error: syntax error, unexpected TOK_EQ, expecting TOK_MINUS or TOK_COMPL or TOK_LP or TOKEN; Input:
=1
^
Oct 27 18:46:09 WARNING[4944]: ast_expr2.fl:187 ast_yyerror: If you have questions, please refer to doc/README.variables in the asterisk source.
– Executing GotoIf(“SIP/8685445-f6322058”, “0?telemarketers|s|1”) in new stack

Please can one of you clever bods sort out the format of this for me, I give up!

Mike.

For what it’s worth the lines in question do function perfectly, the goto does happen if the conditions are met!

Currently I have the following but I still get the same error report, ie…

exten => 3146472,6,GotoIf($[${DB(blockedlist/${CALLERID(number)})}=1]?blocked,s,1) exten => 3146472,7,GotoIf($[${DB(telemarketers/${CALLERID(number)})}=1]?telemarketers,s,1)

Oct 28 19:53:39 WARNING[7030]: ast_expr2.fl:183 ast_yyerror: ast_yyerror(): syntax error: syntax error, unexpected TOK_EQ, expecting TOK_MINUS or TOK_COMPL or TOK_LP or TOKEN; Input:
=1
^
Oct 28 19:53:39 WARNING[7030]: ast_expr2.fl:187 ast_yyerror: If you have questions, please refer to doc/README.variables in the asterisk source.
– Executing GotoIf(“SIP/8685445-0a19ce40”, “0?blocked|s|1”) in new stack
Oct 28 19:53:39 WARNING[7030]: ast_expr2.fl:183 ast_yyerror: ast_yyerror(): syntax error: syntax error, unexpected TOK_EQ, expecting TOK_MINUS or TOK_COMPL or TOK_LP or TOKEN; Input:
=1
^
Oct 28 19:53:39 WARNING[7030]: ast_expr2.fl:187 ast_yyerror: If you have questions, please refer to doc/README.variables in the asterisk source.
– Executing GotoIf(“SIP/8685445-0a19ce40”, “0?telemarketers|s|1”) in new stack

I assume that now I have removed all of the quotes then this would break if I end up with a space char in the caller ID.

Mike.
[/code]

the number portion of a callerid should never have a space. (i think…)

In theory yes, but most documentation appears to suggest that it should still be quoted just in case, but yes, in reality I doubt it would happen.

Mike.

Anyone, any ideas?
I can’t be the only person ever to have used GotoIf with a db query.

Mike.

exten => 320,1,NoOp(${DB(testing/${CALLERID(num)})}) exten => 320,2,GotoIf($[${DB(testing/${CALLERID(num)})} = 1]?5) exten => 320,3,Playback(beep) exten => 320,4,Hangup() exten => 320,5,Playback(tt-weasels) exten => 320,6,Hangup()

works for me

Thanks mate, it is exactly how I had it in the first place!

It seems that it may just give an error just for the heck of it even though it works fine.

I think that one problem is when the number given is not in the db already, thats 99.9% of the calls it takes, then there is no db key specified so it doesn’t like it.

Thanks for your assistance. All incoming lines write the last incoming number to the database. If a user dials 865 it says 'the last caller was 0 1 2 1 . . . etc. and gives the option to put the number into the telesales list or the blacklist.
Future calls from the same number are either given a polite message if telesales, or the unavailable tone for blacklist numbers.

It seems to work really well. :smiley:

Mike.

Old thread but will answer if someone else should stumble upon it.

Correct usage is to include quotation marks.

exten => 3146472,6,GotoIf($["${DB(blockedlist/${CALLERID(number)})}"="1"]?blocked,s,1) exten => 3146472,7,GotoIf($["${DB(telemarketers/${CALLERID(number)})}"="1"]?telemarketers,s,1)

Without quotation if there’s no db entry the evaluation string would resolve to:

When using the quotes then:

and no more error.

Old thread indeed.

Thanks for the assistance, I have no recollection of having posted this, but it seems I did. The solution you stated was exactly what I appear to have done at the time, it is still in the dial plan now and stills works perfectly 7 years on!

Mike.