You have to identify the correct headers dependent on the call context (i.e. which leg did the bridge/forward, the originatee/originator etc).<div><br></div><div>Personally I&#39;ve found that attaching custom headers onto each leg is the best way to keep track things - but like Dave said, this really is a can of worms.</div>

<div><br></div><div>It took me approx 6 months of various code iterations to eventually figure out a way to do this that was suitable for our use case. Several people have said to me &quot;Cal, it&#39;s harder than it looks&quot;... tbh it isn&#39;t, it&#39;s just that the variables and API aren&#39;t exposed in a typically sane fashion, and there is no definitive guide on the patterns to look for or best practices. In short, it isn&#39;t complex, but it might make you bang your head off a wall out of sheer frustration.</div>
<div><br></div><div>You need to ensure you compensate for both blind and attended transfers, and consider what happens if a transfer goes between two domains.. that&#39;s when things get really sticky :)</div>
<div><br></div><div>Cal</div><div><br><div class="gmail_quote">On Mon, May 27, 2013 at 5:01 PM, Jon Schøpzinsky <span dir="ltr">&lt;<a href="mailto:jos@firstcom.dk" target="_blank">jos@firstcom.dk</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi List,<br>
<br>
I am implementing call forwarding on a multi tenant system, and therefore<br>
need to split CDR&#39;s when the call forward happens, so that if the<br>
receiving user also has his account call forwarded, he pays for his part<br>
of the call.<br>
<br>
A calls B<br>
B forwards to C<br>
C forwards to an external mobile phone.<br>
<br>
B has a free call from B to C, but C needs to pay for the forwarding to<br>
the mobile phone. Therefore i need a separate CDR for the C to Mobile<br>
phone call.<br>
<br>
Another example would be this<br>
<br>
A works in Company A, and B works in Company B<br>
They are both users on our system, and therefore is on the same freeswitch.<br>
<br>
A calls B<br>
B Forwards to an external mobile phone.<br>
<br>
Here A needs to pay for the call from A to B, and B needs to pay for the<br>
call being forwarded to his mobile phone.<br>
<br>
Do anybody have an idea as to how to implement this in freeswitch. Back in<br>
my Asterisk days, this would be done by the ForkCDR command.<br>
<br>
<br>
Venlig hilsen/kind regards<br>
<br>
Jon Leren Schøpzinsky<br>
<br>
<br>
_________________________________________________________________________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org" target="_blank">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a><br>
<br>
FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br>
<a href="http://www.cudatel.com" target="_blank">http://www.cudatel.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://wiki.freeswitch.org" target="_blank">http://wiki.freeswitch.org</a><br>
<a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
</blockquote></div><br></div>