GotoIf - Not working If condition is false

Hello, I need to implement an instruction GotoIf in my dialplan to direct the calls for different trunks in function the origin extension, but my instructions not working correctly, always execute the true action independently if the condition is true or false.

The instructions in my Dialplan:

exten => _X.,1,gotoif(${CALLERID(number)}=96XXXXXXX?Provider2,${EXTEN},1)
exten => _X.,1,dial(SIP/${EXTEN}@Provider1,50)
exten => _X.,2,hangup()

[Provider2]

exten => _X.,1,dial(SIP/${EXTEN}@Provider2,50)
exten => _X.,2,hangup()

But only works the Provider2, when the condition is false should work the following priority, but always jump to the context [Provider2].

Please can anybody tell me if I make something bad?

Thank you and apologise for the inconveniences.

Regards

this is always true as you set the callerid to 96XXXXXXX!
If you want to check the callerid you have to put the check between straight brackets []

the right syntax is (not tested)
GotoIf($["${CALLERID(num):2}" = “96”]?Provider2,${EXTEN},1)

Hello, thank you for your fast reply.

I looked for documentation about the topic in Internet and I found examples with the same structure that you indicate me, but this is what happens:

 - extensions.conf:

[outgoing]

exten => _X.,1,GotoIf($["${CALLERID(num):3}" = “107”]?outgoing_2,${EXTEN},1)
exten => _X.,2,set(CALLERID(number)=967175757)
exten => _X.,3,dial(SIP/${EXTEN}@Provider1,50)
exten => _X.,4,hangup()

[outgoing_2]

exten => _X.,1,set(CALLERID(number)=967608487)
exten => _X.,n,dial(SIP/${EXTEN}@Provider2,50)
exten => _X.,n,hangup()

 - console:

== Using SIP RTP CoS mark 5
– Executing [610818983@outgoing:1] GotoIf(“SIP/101-00002be8”, “0?outgoing_2,610818983,1”) in new stack
– Executing [610818983@outgoing:2] Set(“SIP/101-00002be8”, “CALLERID(number)=967175757”) in new stack
– Executing [610818983@outgoing:3] Dial(“SIP/101-00002be8”, “SIP/610818983@Provider1,50”) in new stack
== Using SIP RTP CoS mark 5
– Called SIP/610818983@Provider1
– SIP/Provider1-00002be9 is making progress passing it to SIP/101-00002be8
– SIP/Provider1-00002be9 is ringing
== Spawn extension (start, 610818983, 3) exited non-zero on ‘SIP/101-00002be8’

With this instruction the condition is truncated “0?outgoing_2,610818983,1” and it execute the following priority.

However with the instruction that I indicated in the first post, returns the condition correctly but it does not realize the function correctly.

 - extensions.conf:

[outgoing]

exten => _X.,1,GotoIf(${CALLERID(number)}=101?outgoing_2,${EXTEN},1)
exten => _X.,2,set(CALLERID(number)=967175757)
exten => _X.,3,dial(SIP/${EXTEN}@Provider1,50)
exten => _X.,4,hangup()

[outgoing_2]

exten => _X.,1,set(CALLERID(number)=967608487)
exten => _X.,n,dial(SIP/${EXTEN}@Provider2,50)
exten => _X.,n,hangup()

 - console:

== Using SIP RTP CoS mark 5
– Executing [610818983@outgoing:1] GotoIf(“SIP/107-00002c08”, “107=101?outgoing_2,610818983,1”) in new stack
– Goto (outgoing_2,610217933,1)
– Executing [610818983@outgoing_2:1] Set(“SIP/107-00002c08”, “CALLERID(number)=967608487”) in new stack
– Executing [610818983@outgoing_2:2] Dial(“SIP/107-00002c08”, “SIP/610818983@Provider2,50”) in new stack
== Using SIP RTP CoS mark 5
– Called SIP/610818983@Provider2
– SIP/Provider2-00002c09 is making progress passing it to SIP/107-00002c08
– SIP/Provider2-00002c09 is ringing

Sorry to insist in the topic, but I can’t make the work correctly. Please help me.

Thank you.

You didn’t add the $[…]