GotoIf() with multiple conditions

Hi a quick question.

Does gotoif() supports the AND and OR operator. The documentation does not mention anything about it

https://docs.asterisk.org/Asterisk_20_Documentation/API_Documentation/Dialplan_Applications/GotoIf/?h=gotoif()

same => n,GotoIf($[${value1}=1 && ${value2}=2]?ctbVariableRefSuccess,1,1:ctbVariableRefFailed,1,1)

same => n,GotoIf($[${value1}=1 || ${value2}=2]?ctbVariableRefSuccess,1,1:ctbVariableRefFailed,1,1)

GoToIf only supports the values 0 and 1, and some synonyms.

However everything in $[…] is reduced to a single value before the application is invoked, so any logical operators within these brackets will be taken into consideration in determining the destination of the GoTo. (The dialplan interpreter is a macro processor and the application sees the result of that macro processing.)

Your & and | operators are wrong, see Asterisk Dialplan Expressions

Try this:

same => n,GotoIf($[$[${value1}=1 & ${value2}=2]]?ctbVariableRefSuccess,1,1:ctbVariableRefFailed,1,1)

same => n,GotoIf($[$[${value1}=1 | ${value2}=2]]?ctbVariableRefSuccess,1,1:ctbVariableRefFailed,1,1)

Thank you I can work with that.

That was wrong. Try this:

same => n,GotoIf($[$[${value1}=1] & $[${value2}=2]]?ctbVariableRefSuccess,1,1:ctbVariableRefFailed,1,1)

same => n,GotoIf($[$[${value1}=1] | $[${value2}=2]]?ctbVariableRefSuccess,1,1:ctbVariableRefFailed,1,1)

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