[default] exten => _91NXXNXXXXXX,1,Macro(callerid-fixup,5042743301) exten => _91NXXNXXXXXX,2,Dial(Zap/g1/${EXTEN:1}) exten => 2101,1,Macro(callerid-fixup) exten => 2101,2,Dial(SIP/2101) [macro-callerid-fixup] ; ; This macro assumes the following: ; Extensions without a DID number have a CallerID number that is 4 digits ; Extensions with a DID number have their CallerID number set to their 10 digit DID ; The last 4 digits of a DID number is the same as the extension number ; ; This macro does the following if it is called without any parameters: ; If the Caller*ID number is 4 digits, do nothing ; If the Caller*ID number is not 4 digits, strip off the first 6 digits ; ; This macro does the following if it is called with a parameter ; If the Caller*ID number is 4 digits, reset the Caller*ID number to be the value of the parameter ; If the Caller*ID number is not 4 digits, do nothing ; exten => s,1,NoOp(Entering Macro "callerid-fixup") exten => s,2,NoOp(Variable CALLERIDNUM is equal to ${CALLERIDNUM}) exten => s,3,GoToIf($["${ARG1}" != ""]?external,1) exten => s,4,GoToIf($["${ARG1}" = ""]?internal,1) exten => internal,1,GoToIf($[${LEN(${CALLERIDNUM})} = 4]?e,1) exten => internal,2,SetCIDNum(${CALLERIDNUM:6}) exten => internal,3,GoTo(e,1) exten => external,1,GoToIf($[${LEN(${CALLERIDNUM})} = 4]?e,1) exten => external,2,SetCIDNum(${ARG1},a) exten => external,3,GoTo(e,1) exten => e,1,NoOp(Variable CALLERIDNUM is equal to ${CALLERIDNUM}) exten => e,2,NoOp(Leaving Macro "callerid-fixup")