FreePBX | Register | Issues | Wiki | Portal | Support

Prepend digits to outbound DID


(Lorne Gaetz) #21

[quote=“dickson, post:20, topic:38149”]
I will stop with solutions that use the _override file and code for custom context from now on.[/quote]

Sometimes you don’t have a choice, and you have to use override, but only as a last resort. And always add noop lines when using custom dialplan so the poor bugger who has to maintain it in a few years time gets some breadcrumbs in the full log with clues to what’s going on.


(Dickson) #22

Yea, I normally leave NoOps in my examples, I think I removed them from the code i lieu of explaining the each statement line by line.

So, for your example (I went to 4 production machines and implemented your one liner btw), using _custom.conf file, whats the best way to trigger the code at the appropriate time? I feel pretty comfortable with dialplan, but I’m having a hard time wrapping my head around how to inject this into a dialplan without using an _override. Old dog who wants to learn some new tricks though!

EDIT:
Forgot, that in order to make it work with the code I had in place, I had to use USEROUTCID.

exten => s,n,ExecIf($[${LEN(${CALLERID(number)})}=3]?Set(USEROUTCID="${CALLERID(Name)}" <4${CALLERID(number)}>)

Its made the CLID’s lower case though, so working on that…


(Lorne Gaetz) #23

If the appropriate time is at every outbound call, then there is a context reserved specifically for that, use [macro-dialout-trunk-predial-hook]


(Dickson) #24

Oh frig yes. I didn’t realize it was that easy calling it. That is good to know. I will revise my implementations instructions. Thanks! I’ve learned a new better trick.


#25

Hi lgaetz

Thank you for taking the time to respond.
Can this be used only out one trunk and not the others?
Can I specify different numbers to be added in front the extension number for different trunks?


(Lorne Gaetz) #26

Outbound route name is stored in a channel variable “OUTBOUND_ROUTE_NAME” so you can check that value and do whatever you want based on the result. There would be an easier method to do this but I recently uncovered a bug that prevents you from running a subroutine as an intra-company dial option.


#27

Let’s say the outbound route is named test_outbound_route
How would I use the procedure to change the caller id only for this route?
Thank you in advance.


(Lorne Gaetz) #28
exten => s,n,ExecIf($["${OUTBOUND_ROUTE_NAME}"="test_outbound_route"]?Set(CALLERID(number)=4${CALLERID(number)}))

(Dickson) #29

Igaetz, you’ve mentioned this variable in some other posts, but the versions I test with (FreePBX Distros) that variable always returns null. This would be super handy to have populated in the logs for troubleshooting, and I’ve always wanted it, but couldn’t make it work.


(Lorne Gaetz) #30

Shoot, I forgot the important part, you must enable ‘NoOp Traces in Dialplan’ in advanced settings. Level 1 or higher.


(Dickson) #31

This. This is fantastic!


(Dickson) #32

Is there a list of other FreePBX variables like this (as well as .conf contexts) anywhere that I can use as a reference for other dialplans?


(Lorne Gaetz) #33

No. Become one with DumpChan it will tell you everything.


#34

Hi lgaetz,
I’m trying to get this to work but I cant.
I can’t establish a call.
Do I add this

`exten => s,n,ExecIf($["${OUTBOUND_ROUTE_NAME}"="test_outbound_route"]?Set(CALLERID(number)=4${CALLERID(number)}))`

like this:

[macro-dialout-trunk-predial-hook]
exten => s,1,Noop(Entering user defined context [macro-dialout-trunk-predial-hook] in extensions_custom.conf)
exten => s,n,ExecIf($["${OUTBOUND_ROUTE_NAME}"="test_outbound_route"]?Set(CALLERID(number)=4${CALLERID(number)}))
exten => s,n,MacroExit

Or do I create a new context and set this context under the trunk configuration?
I tried everything and it didn’t work. I also set NoOp Traces in Dialplan to 1 as you suggested.
If it’s important I’m trying to do this on Elastix 2.5 (FreePBX 2.11).


(Lorne Gaetz) #35

I would consider it important to mention that you are running an end of life, unsupported version. You appear to be doing things right, but who knows what Elastix has done with their fork. I recommending migrating to a supportable system.