Macro dialout-trunk clears CALLERID(number) when failing through to other trunks if the call is routed from one trunk to another.
The Asterisk is used to connect two sites and route the calls between them.
Site A <---> Asterisk <---> Site B
Trunks from Site A or B to Asterisk have context=from-internal.
Outbound Routes from Asterisk to the Sites have more than one trunk (using trunk sequence).
When one trunk fail Asterisk will try other trunks executes the following:
exten => continue,n(noreport),Noop(TRUNK Dial failed due to ${DIALSTATUS} HANGUPCAUSE: ${HANGUPCAUSE} - failing through to other trunks)
exten => continue,n,Set(CALLERID(number)=${AMPUSER})
But ${AMPUSER} is empty causing the CALLERID(number) to be cleared. Adding an ExecIf? to check if ${AMPUSER} is not empty solves the problem.
exten => continue,n,ExecIf($["${AMPUSER}" != ""]?Set(CALLERID(number)=${AMPUSER}))