I noticed that something important has changed at this point. I don’t have a full understanding of “the new method”. Investigating and reading many docs I found a solution which seems to work for me:
There are functions which are adding these headers to the sip data stream. The function uses the SIPHEADERS variable to fetch custom/new/addtional headers. So I added the following code to the “old” [macro-dialout-trunk-predial-hook]:
[macro-dialout-trunk-predial-hook]
exten => s,1,NoOp(******************** PRE DIAL HOOK ********************)
; sipgate trunk
exten => s,n,GotoIf($[ "${TRUNKOUTCID}" = "<CID OF TRUNK>" ]?sipgate_cid)
exten => s,n,MacroExit()
; Setting P-Preferred-Identity at sipgate trunk for custom caller id
exten => s,n(sipgate_cid),Set(HASH(_SIPHEADERS,P-Preferred-Identity)=<sip:${CALLERID(num)}@sipconnect.sipgate.de>)
exten => s,n,MacroExit()