Indeed, calling this function from a branch_route works fine.

The only thing i noticed is the following messages in the log file:

uac [replace.c:396]: replace_uri(): Already called uac_replace for this dialog
uac [replace.c:405]: replace_uri(): Deleted <_uac_tonew> var in dialog
uac [replace.c:396]: replace_uri(): Already called uac_replace for this dialog
uac [replace.c:405]: replace_uri(): Deleted <_uac_funew> var in dialog

As they are with INFO LogLevel - I'm just ignoring it for now.
Thank you Sergiu/Alex

On Fri, 7 Aug 2020 at 22:12, Alex Balashov <abalashov@evaristesys.com> wrote:
Another option is to put the uac_replace_from() calls into a
branch_route, or a request-route subroutine that is called from a
branch_route. The lump changes will then be made on a per-branch basis
only and reverted on the next branch.

-- Alex

On 8/7/20 4:41 PM, Sergiu Pojoga wrote:
> Calling t_save_lumps() before the changes are made and before t_relay()
> might help, so that upon failure, Kam restores the SIP message to the
> original state and then further apply desired changes.
>
> Cheers,
> --Sergiu
>
> On Fri, Aug 7, 2020 at 3:39 PM Ilie Soltanici <iliusha.md@gmail.com
> <mailto:iliusha.md@gmail.com>> wrote:
>
>     Hello,
>
>     We are using a few carries where we are sending calls to, each of
>     them is using a special prefix in the From header in order to manage
>     the callerid. Some of them are not recognizing headers like
>     P-Asserted-Identity or Remote-Party-ID, so for them we have to
>     replace the From header with the corresponding prefix. The way we do
>     - it's by using the uac_replace_from function, which works fine.
>     The problem is when we are sending the same call to the failover
>     trunk, and that trunk is using a different prefix. We have to call
>     again the uac_replace_from function which is appending the new
>     prefix to the existing one, something like:
>
>     From: <sip:12345@domain.localsip:+12345@domain.local>;tag=as404cb50c
>
>     I was trying to use uac_restore_from() function and call again
>     uac_replace_from, but the result is the same.
>
>     Is there any way to call the uac_restore_from function twice for the
>     same call?
>     Thank you.
>     _______________________________________________
>     Kamailio (SER) - Users Mailing List
>     sr-users@lists.kamailio.org <mailto:sr-users@lists.kamailio.org>
>     https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>
>
> _______________________________________________
> Kamailio (SER) - Users Mailing List
> sr-users@lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>

--
Alex Balashov | Principal | Evariste Systems LLC

Tel: +1-706-510-6800 / +1-800-250-5920 (toll-free)
Web: http://www.evaristesys.com/, http://www.csrpswitch.com/

_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users