Dynamic Routing with MySQL - Additional Question

Hi all,
the original thread was solved and works quite well. However we are using this feature more often now. And there is a problem sending the correct caller…

“from-internal,${DYNROUTE_tasfb},1” also tried from-did-direct and other contexts.

I always get the central number (trunk) sent when I forward the calls to a external number (e.g. a mobilephone). But just with this approach.
Internal forwarding works perfect and I also see the correct number.

Even if I configure all mobile numbers seperately and put them in the Extensions → optional destinations I see the correct calling number.

Can anybody help? Thanks in advance.

Best regards,

Hi all,
found a solution somehow - I added a custom context.

However now for internal calls the CID is not working anymore. Any tips how I can Goto the correct context for CID?

; Hier prüfen wir, ob die Variable RestrictCID gesetzt ist
exten => _X.,1,GotoIf($[“${RestrictCID}” = “yes”]?skip:proceed)

exten => _X.,n(proceed),NoOp(Verarbeitung des Anrufs für ${EXTEN} ohne CID Manipulation)
exten => _X.,n,Set(RestrictCID=yes)
exten => _X.,n,Set(CALLERID(num-pres)=allowed_not_screened) ; Erlaubt, aber nicht geprüft
exten => _X.,n,Set(CALLERID(name-pres)=allowed_not_screened) ; Erlaubt, aber nicht geprüft
; Überprüfen, ob die Länge von ${EXTEN} kleiner oder gleich 5 ist
exten => _X.,n,GotoIf($[${LEN(${EXTEN})} <= 5]?intern:extern)

; Interne Weiterleitung, wenn Länge <= 5
exten => _X.,n(intern),Dial(PJSIP/${EXTEN})
exten => _X.,n,Goto(end)

; Externe Weiterleitung, wenn Länge > 5
exten => _X.,n(extern),Dial(PJSIP/${EXTEN}@Telekom_SIP-TRUNK)
exten => _X.,n,Goto(end)