Correct syntax for "Or" condition in GotoIf command

I am not sure about the correct syntax of an “or” condition in a GotoIF statement, in particular the use of square brackets.

Which of below four possibilities is correct?

exten => s,1,GotoIf($["${CALLERID(num)}" = “1000” | “${CALLERID(num)}” = “2000”]?2:3)

exten => s,1,GotoIf($[$["${CALLERID(num)}" = “1000”] | $["${CALLERID(num)}" = “2000”]]?2:3)

exten => s,1,GotoIf($["${CALLERID(num)}" = “1000”] | $["${CALLERID(num)}" = “2000”]?2:3)

exten => s,1,GotoIf($["${CALLERID(num)}" = “1000” | $["${CALLERID(num)}" = “2000”]?2:3)

My suggestion would be to use the following dialplan:

exten => s,1,NoOp()
same => n,GotoIf($["${CALLERID(num)}"="1000"]?true)
same => n,GotoIf($["${CALLERID(num)}"="2000"]?true)
same => n(false),NoOp(False)
same => n,Hangup()
same => n(true),NoOp(True)
same => n,Hangup()

Are you sure?
Both Asterisk wiki and other threads suggest you can do GotoIF statements with several “Or” conditions.
http://forums.asterisk.org/viewtopic.php?f=1&t=74354

https://wiki.asterisk.org/wiki/display/AST/Operators

The first one.

However, also consider ex-girlfriend logic:

s/_[12]000

1 Like

Apologies, I will edit my post to remove the incorrect statement.

I’m a fan of doing it with a regex.

exten => 1000,1,NoOP()
same => n,Answer()
same => n,Set(MyNumber=2000)
same => n,NoOP(MyNumber is ${MyNumber})
same => n,ExecIf($[${MyNumber}:“1000|2000”]?Playback(demo-congrats)
same => n,Playback(goodbye)
same => n,Hangup()

1 Like