<html>
<head>
    <base href="https://wiki.asterisk.org/wiki">
            <link rel="stylesheet" href="/wiki/s/en/2172/18/9/_/styles/combined.css?spaceKey=AST&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+Application_ForkCDR">Asterisk 11 Application_ForkCDR</a></h2>
    <h4>Page  <b>added</b> by             <a href="https://wiki.asterisk.org/wiki/display/~wikibot">Wiki Bot</a>
    </h4>
         <br/>
    <div class="notificationGreySide">
         <h1><a name="Asterisk11Application_ForkCDR-ForkCDR%28%29"></a>ForkCDR()</h1>

<h3><a name="Asterisk11Application_ForkCDR-Synopsis"></a>Synopsis</h3>

<p>Forks the Call Data Record.</p>
<h3><a name="Asterisk11Application_ForkCDR-Description"></a>Description</h3>



<p>Causes the Call Data Record to fork an additional cdr record starting from the time of the fork call. This new cdr record will be linked to end of the list of cdr records attached to the channel.The original CDR has a LOCKED flag set, which forces most cdr operations to skip it, except for the functions that set the answer and end times, which ignore the LOCKED flag. This allows all the cdr records in the channel to be 'ended' together when the channel is closed.</p>

<p>The CDR() func (when setting CDR values) normally ignores the LOCKED flag also, but has options to vary its behavior. The 'T' option (described below), can override this behavior, but beware the risks.</p>

<p>First, this app finds the last cdr record in the list, and makes a copy of it. This new copy will be the newly forked cdr record. Next, this new record is linked to the end of the cdr record list. Next, The new cdr record is RESET (unless you use an option to prevent this)</p>

<p>This means that:</p>

<p>1. All flags are unset on the cdr record</p>

<p>2. the start, end, and answer times are all set to zero.</p>

<p>3. the billsec and duration fields are set to zero.</p>

<p>4. the start time is set to the current time.</p>

<p>5. the disposition is set to NULL.</p>

<p>Next, unless you specified the <tt>v</tt> option, all variables will be removed from the original cdr record. Thus, the <tt>v</tt> option allows any CDR variables to be replicated to all new forked cdr records. Without the <tt>v</tt> option, the variables on the original are effectively moved to the new forked cdr record.</p>

<p>Next, if the <tt>s</tt> option is set, the provided variable and value are set on the original cdr record.</p>

<p>Next, if the <tt>a</tt> option is given, and the original cdr record has an answer time set, then the new forked cdr record will have its answer time set to its start time. If the old answer time were carried forward, the answer time would be earlier than the start time, giving strange duration and billsec times.</p>

<p>If the <tt>d</tt> option was specified, the disposition is copied from the original cdr record to the new forked cdr. If the <tt>D</tt> option was specified, the destination channel field in the new forked CDR is erased. If the <tt>e</tt> option was specified, the 'end' time for the original cdr record is set to the current time. Future hang-up or ending events will not override this time stamp. If the <tt>A</tt> option is specified, the original cdr record will have it ANS_LOCKED flag set, which prevent future answer events from updating the original cdr record's disposition. Normally, an <tt>ANSWERED</tt> event would mark all cdr records in the chain as <tt>ANSWERED</tt>. If the <tt>T</tt> option is specified, the original cdr record will have its <tt>DONT_TOUCH</tt> flag set, which will force the cdr_answer, cdr_end, and cdr_setvar functions to leave that cdr record alone.</p>

<p>And, last but not least, the original cdr record has its LOCKED flag set. Almost all internal CDR functions (except for the funcs that set the end, and answer times, and set a variable) will honor this flag and leave a LOCKED cdr record alone. This means that the newly created forked cdr record will be affected by events transpiring within Asterisk, with the previously noted exceptions.</p>

<h3><a name="Asterisk11Application_ForkCDR-Syntax"></a>Syntax</h3>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>ForkCDR(options)</pre>
</div></div>
<h5><a name="Asterisk11Application_ForkCDR-Arguments"></a>Arguments</h5>


<ul>
        <li>options
        <ul>
                <li>a - Update the answer time on the NEW CDR just after it's been inited. The new CDR may have been answered already. The reset that forkcdr does will erase the answer time. This will bring it back, but the answer time will be a copy of the fork/start time. It will only do this if the initial cdr was indeed already answered.</li>
                <li>A - Lock the original CDR against the answer time being updated. This will allow the disposition on the original CDR to remain the same.</li>
                <li>d - Copy the disposition forward from the old cdr, after the init.</li>
                <li>D - Clear the <tt>dstchannel</tt> on the new CDR after reset.</li>
                <li>e - End the original CDR. Do this after all the necessary data is copied from the original CDR to the new forked CDR.</li>
                <li>r - Do <b>NOT</b> reset the new cdr.</li>
                <li>s(name=val) - Set the CDR var <em>name</em> in the original CDR, with value <em>val</em>.</li>
                <li>T - Mark the original CDR with a DONT_TOUCH flag. setvar, answer, and end cdr funcs will obey this flag; normally they don't honor the LOCKED flag set on the original CDR record.</li>
                <li>v - When the new CDR is forked, it gets a copy of the vars attached to the current CDR. The vars attached to the original CDR are removed unless this option is specified.</li>
        </ul>
        </li>
</ul>


<h3><a name="Asterisk11Application_ForkCDR-SeeAlso"></a>See Also</h3>


<ul>
        <li><a href="/wiki/pages/createpage.action?spaceKey=AST&amp;title=Asterisk+11+Function_CDR&amp;linkCreation=true&amp;fromPageId=20187009" class="createlink">Asterisk 11 Function&#95;CDR</a></li>
        <li><a href="/wiki/display/AST/Asterisk+11+Application_NoCDR" title="Asterisk 11 Application_NoCDR">Asterisk 11 Application&#95;NoCDR</a></li>
        <li><a href="/wiki/pages/createpage.action?spaceKey=AST&amp;title=Asterisk+11+Application_ResetCDR&amp;linkCreation=true&amp;fromPageId=20187009" class="createlink">Asterisk 11 Application&#95;ResetCDR</a></li>
</ul>


<h3><a name="Asterisk11Application_ForkCDR-ImportVersion"></a>Import Version</h3>

<p>This documentation was imported from Asterisk Version SVN-trunk-r370322</p>
    </div>
    <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;" class="grey">
                        <a href="https://wiki.asterisk.org/wiki/users/removespacenotification.action?spaceKey=AST">Stop watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://wiki.asterisk.org/wiki/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
       <a href="https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+Application_ForkCDR">View Online</a>
              |
       <a href="https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+Application_ForkCDR?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
           </div>
</div>
</div>
</div>
</div>
</body>
</html>