Transfer call from Lync trunk, have a problem

Hello,
I realize the routing of the trunk “Lync” on trunks different operators using CallerID Number mask like this: “_210 [0-9] X”. This user number “Lync”. Up goes the desired regional SIP trunk.
Since this is no problem, but if you do a direct transfer a call to the SIP header substituted caller’s number:

<— SIP read from TCP:192.168.114.39:53346 —>
INVITE sip:555555@srv-astregion-01.enterprise.local;user=phone SIP/2.0
FROM: "Ivan Petrov"sip:50100@mydomain.ru;user=phone;epid=9C19827BFD;tag=93e78c79ae
TO: sip:555555@srv-astregion-01.enterprise.local;user=phone
CSEQ: 2218865 INVITE
CALL-ID: d658499f-3715-4b7b-9a4f-f9eb22b0dc90
MAX-FORWARDS: 70
VIA: SIP/2.0/TCP 192.168.114.39:53346;branch=z9hG4bKbf9786bd
CONTACT: sip:Srv-LyncME-01.enterprise.local:5068;transport=Tcp;maddr=192.168.114.39;ms-opaque=65860a8a0c3aa10e
CONTENT-LENGTH: 348
REFERRED-BY: sip:21001@Srv-LyncME-01.enterprise.local;user=phone
SUPPORTED: 100rel
USER-AGENT: RTCC/5.0.0.0 MediationServer
CONTENT-TYPE: application/sdp
ALLOW: ACK
Allow: CANCEL,BYE,INVITE,PRACK,UPDATE

me need using number 21001, this user realize call trunsfer.

“Lync” sends the number of the one who takes the field "REFERRED-BY: "
How do I implement inbound routing on the field, or spoofing CallerID Number on the field if it is not empty?
Thank you!

You need to inspect ${SIP_HEADER(REFERRED-BY)} in this case.

I understand, but how to do it?
I set up routing via “GUI”
srv-astregion-01 * CLI> dialplan show from-trunk-sip-Lync_COD
[Context ‘from-trunk-sip-Lync_COD’ created by ‘pbx_config’]
‘_.’ => 1. Set (GROUP () = OUT_4) [pbx_config]
2. Goto (from-trunk, $ {EXTEN}, 1) [pbx_tsonfigsch

I understand that I need to do what that custom context??
And then send it to trunk with a modified “CID”
If possible, give the code. outline

Thanks for your response!

Consult the person or organisation that wrote your dialplan. In particular, FreePBX is not supported here.

That use of referred-by doesn’t look valid to me. I’d only expect it on a REFER request.