ODBC & extensions_custom.conf

Hi

I am using Asterisk 11.3.0 with FreePBX 2.7.0.3
I am a newbe with this and any help will be appreciated.
I want asterisk to log all outbound calls in our CRM Database.
We are using PostgressSQL with a custom CRM Application.
But asterisk don’t want to execute the functions.
So I have done the following:

func_odbc.conf:

[LOG_GET_USERID]
dsn=django_odbc
readsql=SELECT ${ARG1} FROM userprofile WHERE asterisk_extension = ‘${ARG2}’

[LOG_GET_CONTACT1]
dsn=django_odbc
readsql=SELECT ${ARG1},${ARG2} FROM contact WHERE ${ARG3} = ‘${ARG4}’

[LOG_GET_CLIENT1]
dsn=django_odbc
readsql=SELECT ${ARG1},${ARG2} FROM client WHERE ${ARG3} = ‘${ARG4}’

[LOG_INTERACTION_OUTBOUND]
dsn=django_odbc
write=INSERT INTO call (subject,spoke_to,description,status,direction,date_start,assign_to_id,created_at,updated_at,sugarcrm_id) VALUE$ (‘To ${VAL2}’,’?’,’${VAL8} - ${VAL9} - ${VAL3} - ${VAL4} - ${VAL6}’,‘Not_Held’,‘Outbound’,’${VAL5}’,’${VAL7}’,’${VAL5}’,’${VAL5}’,’${VAL1}’);


I have tested it and it does “Insert” in our CRM Table.
So problem with connection.

My problem is with the executing of the functions.
Here are my extensions *.conf

extensions_additional.conf:

[from-trunk-sip-iConnect] ; Outbound Calls
include => from-trunk-sip-iConnect-custom
exten => _.,1,Set(GROUP()=OUT_3)
exten => _.,n,Goto(from-trunk,${EXTEN},1)

; end of [from-trunk-sip-iConnect]

[from-trunk-iax2-LinkMX2HQ-peer] ;Internal Calls/Backup Outbound
include => from-trunk-iax2-LinkMX2HQ-peer-custom
exten => _.,1,Set(GROUP()=OUT_4)
exten => _.,n,Goto(from-trunk,${EXTEN},1)

; end of [from-trunk-iax2-LinkMX2HQ-peer]

[from-trunk-iax2-LinkMX2SB-peer] ;Internal Calls
include => from-trunk-iax2-LinkMX2SB-peer-custom
exten => _.,1,Set(GROUP()=OUT_5)
exten => _.,n,Goto(from-trunk,${EXTEN},1)

; end of [from-trunk-iax2-LinkMX2SB-peer]

[from-trunk-iax2-LinkMX2SC-peer] ;Internal Calls
include => from-trunk-iax2-LinkMX2SC-peer-custom
exten => _.,1,Set(GROUP()=OUT_6)
exten => _.,n,Goto(from-trunk,${EXTEN},1)

; end of [from-trunk-iax2-LinkMX2SC-peer]

[from-trunk-iax2-LinkMX2SM-peer] ;Internal Calls
include => from-trunk-iax2-LinkMX2SM-peer-custom
exten => _.,1,Set(GROUP()=OUT_7)
exten => _.,n,Goto(from-trunk,${EXTEN},1)

; end of [from-trunk-iax2-LinkMX2SM-peer]

[from-trunk-iax2-LinkMX2NL-peer] ;Internal Calls
include => from-trunk-iax2-LinkMX2NL-peer-custom
exten => _.,1,Set(GROUP()=OUT_8)
exten => _.,n,Goto(from-trunk,${EXTEN},1)

; end of [from-trunk-iax2-LinkMX2NL-peer]

[from-trunk-iax2-LinkMX2IM-peer] ;Internal Calls
include => from-trunk-iax2-LinkMX2IM-peer-custom
exten => _.,1,Set(GROUP()=OUT_9)
exten => _.,n,Goto(from-trunk,${EXTEN},1)

; end of [from-trunk-iax2-LinkMX2IM-peer]

[from-trunk-iax2-LinkMX2DW-peer] ;Internal Calls
include => from-trunk-iax2-LinkMX2DW-peer-custom
exten => _.,1,Set(GROUP()=OUT_11)
exten => _.,n,Goto(from-trunk,${EXTEN},1)

; end of [from-trunk-iax2-LinkMX2DW-peer]

[outbound-allroutes]
include => outbound-allroutes-custom
include => outrt-001-SM
include => outrt-002-SB
include => outrt-003-SCF
include => outrt-004-HQ
include => outrt-005-InterOffice_IM
include => outrt-006-InterOffice_NL
include => outrt-007-InterOffice_DW
include => outrt-008-Local_Mobile
exten => foo,1,Noop(bar)

; end of [outbound-allroutes]

[outrt-001-SM] ;InterOffice
include => outrt-001-SM-custom
exten => _12XX,1,Macro(user-callerid,SKIPTTL,)
exten => _12XX,n,Set(INTRACOMPANYROUTE=YES)
exten => _12XX,n,ExecIf($["${KEEPCID}"!=“TRUE” & ${LEN(${DB(AMPUSER/${AMPUSER}/outboundcid)}}=0 & ${LEN(${TRUNKCIDOVERRIDE}}=0]?Set(TRUNKCIDOVERRIDE=SM))
exten => _12XX,n,Set(_NODEST=)
exten => _12XX,n,Macro(record-enable,${AMPUSER},OUT,)
exten => _12XX,n,Macro(dialout-trunk,7,${EXTEN},)
exten => _12XX,n,Macro(outisbusy,)

; end of [outrt-001-SM]

[outrt-002-SB] ;InterOffice
include => outrt-002-SB-custom
exten => _14XX,1,Macro(user-callerid,SKIPTTL,)
exten => _14XX,n,Set(INTRACOMPANYROUTE=YES)
exten => _14XX,n,ExecIf($["${KEEPCID}"!=“TRUE” & ${LEN(${DB(AMPUSER/${AMPUSER}/outboundcid)}}=0 & ${LEN(${TRUNKCIDOVERRIDE}}=0]?Set(TRUNKCIDOVERRIDE=SB))
exten => _14XX,n,Set(_NODEST=)
exten => _14XX,n,Macro(record-enable,${AMPUSER},OUT,)
exten => _14XX,n,Macro(dialout-trunk,5,${EXTEN},)
exten => _14XX,n,Macro(outisbusy,)
exten => _20X,1,Macro(user-callerid,SKIPTTL,)
exten => _20X,n,Set(INTRACOMPANYROUTE=YES)
exten => _20X,n,ExecIf($["${KEEPCID}"!=“TRUE” & ${LEN(${DB(AMPUSER/${AMPUSER}/outboundcid)}}=0 & ${LEN(${TRUNKCIDOVERRIDE}}=0]?Set(TRUNKCIDOVERRIDE=SB))
exten => _20X,n,Set(_NODEST=)
exten => _20X,n,Macro(record-enable,${AMPUSER},OUT,)
exten => _20X,n,Macro(dialout-trunk,5,${EXTEN},)
exten => _20X,n,Macro(outisbusy,)

; end of [outrt-002-SB]

[outrt-003-SCF] ;InterOffice
include => outrt-003-SCF-custom
exten => _16XX,1,Macro(user-callerid,SKIPTTL,)
exten => _16XX,n,Set(INTRACOMPANYROUTE=YES)
exten => _16XX,n,ExecIf($["${KEEPCID}"!=“TRUE” & ${LEN(${DB(AMPUSER/${AMPUSER}/outboundcid)}}=0 & ${LEN(${TRUNKCIDOVERRIDE}}=0]?Set(TRUNKCIDOVERRIDE=SCF))
exten => _16XX,n,Set(_NODEST=)
exten => _16XX,n,Macro(record-enable,${AMPUSER},OUT,)
exten => _16XX,n,Macro(dialout-trunk,6,${EXTEN},)
exten => _16XX,n,Macro(outisbusy,)

; end of [outrt-003-SCF]

[outrt-004-HQ] ;InterOffice
include => outrt-004-HQ-custom
exten => _15XX,1,Macro(user-callerid,SKIPTTL,)
exten => _15XX,n,Set(INTRACOMPANYROUTE=YES)
exten => _15XX,n,Set(_NODEST=)
exten => _15XX,n,Macro(record-enable,${AMPUSER},OUT,)
exten => _15XX,n,Macro(dialout-trunk,4,${EXTEN},)
exten => _15XX,n,Macro(outisbusy,)

; end of [outrt-004-HQ]

[outrt-005-InterOffice_IM] ;InterOffice
include => outrt-005-InterOffice_IM-custom
exten => _23XX,1,Macro(user-callerid,SKIPTTL,)
exten => _23XX,n,Set(INTRACOMPANYROUTE=YES)
exten => _23XX,n,Set(_NODEST=)
exten => _23XX,n,Macro(record-enable,${AMPUSER},OUT,)
exten => _23XX,n,Macro(dialout-trunk,9,${EXTEN},)
exten => _23XX,n,Macro(outisbusy,)

; end of [outrt-005-InterOffice_IM]

[outrt-006-InterOffice_NL] ;InterOffice
include => outrt-006-InterOffice_NL-custom
exten => _18XX,1,Macro(user-callerid,SKIPTTL,)
exten => _18XX,n,Set(INTRACOMPANYROUTE=YES)
exten => _18XX,n,Set(_NODEST=)
exten => _18XX,n,Macro(record-enable,${AMPUSER},OUT,)
exten => _18XX,n,Macro(dialout-trunk,8,${EXTEN},)
exten => _18XX,n,Macro(outisbusy,)

; end of [outrt-006-InterOffice_NL]

[outrt-007-InterOffice_DW] ;InterOffice
include => outrt-007-InterOffice_DW-custom
exten => _21XX,1,Macro(user-callerid,SKIPTTL,)
exten => _21XX,n,Set(INTRACOMPANYROUTE=YES)
exten => _21XX,n,Set(_NODEST=)
exten => _21XX,n,Macro(record-enable,${AMPUSER},OUT,)
exten => _21XX,n,Macro(dialout-trunk,11,${EXTEN},)
exten => _21XX,n,Macro(outisbusy,)

; end of [outrt-007-InterOffice_DW]

[outrt-008-Local_Mobile] ;OUT GOING TRUNC
include => outrt-008-Local_Mobile-custom
exten => _XX.,1,Macro(user-callerid,SKIPTTL,)
exten => _XX.,n,Set(_NODEST=)
exten => _XX.,n,Macro(record-enable,${AMPUSER},OUT,)
exten => _XX.,n,Macro(dialout-trunk,3,${EXTEN},)
exten => _XX.,n,Macro(dialout-trunk,4,${EXTEN},)
exten => _XX.,n,Macro(outisbusy,)

; end of [outrt-008-Local_Mobile]

extensions_custom.conf :

[outrt-008-Local_Mobile-custom]
exten => _XX.,1,Set(CRMUSERID=${ODBC_LOG_GET_USERID(user_id,${CALLERID(number)})})
exten => _XX.,n,Set(CONTACT1=${ODBC_LOG_GET_CONTACT1(firstname,surname,cellular,${EXTEN})})
exten => _XX.,n,Set(CLIENT1=${ODBC_LOG_GET_CLIENT1(global_id,name,phone_office,${EXTEN})})
exten => _XX.,n,Set(ODBC_LOG_INTERACTION_OUTBOUND()=${UNIQUEID},${EXTEN},${CHANNEL},${CONTEXT},${STRFTIME(${EPOCH},%Y-%m-%d %H:%M:%S)},${CALLERID(number)},${CRMUSERID},${CONTACT1},${CLIENT1})


Can someone please help me in the right direction?
Not 100% sure what I am doing wrong.

I also need to log all the incoming calls on our “Queue 100”, but I 1st want to fix the logging of the outbound calls.

Someone told me that, the include for outrt-008-Local_Mobile-custom in outrt-008-Local_Mobile will be ineffective, because there are equally good matches for all priorities of all extension in outrt-008-Local_Mobile and actually matches for rather more priorities. If I go direct to outrt-008-Local_Mobile-custom, none of the priorities will actually initiate an outbound call.

Can someone please help to explain this. I am not 100% sure how it must be setup and what I am doing wrong.

Thanks
Hendrik