title: Asterisk channel variable persistence when transferring calls
body: <p>Using Asterisk as the PBX for a client and they have a situation I can't seem to program my way around.</p>
  
  <p>They have taken in a bunch of DDI's to act as an agent for a number of companies - almost like a secretarial type situation.</p>
  
  <p>What the client wants is an easy way to transfer this to the intended company (they understand they'll be paying for the outbound leg of the call).  They don't want a huge pause while someone looks up the number in an online directory etc.  This is a huge use-case for click-to-call but I can't find a way to tie the extension to the workstation of the user easily (that the client will actually implement) (note, I can't get them to use queues either and a ring strategy that doesn't have 34 home workers all hearing the phone ring at once so lets not get into that debate).</p>
  
  <p>I gave this some thought and figured that I could make a ghost extension like 5678 that could do this and the call taker would just put the call on hold, transfer to the ghost extension and some logic would make that into an outbound call</p>
  
  <p>So off I went to write some extension logic to store the </p>
  
  <p>Call arrives via DDI 1, I can get the number that was called (note, not the caller ID of the person calling) via <code>${CALLERID(dnid)}</code> just fine.</p>
  
  <p>I stored this in a variable.</p>
  
  <p>Made a call to the DDI, received it, blind transferred it and bam - I can see the value in the variable in the receiving extensions logic.....</p>
  
  <p>But!!!!</p>
  
  <p>Made a call to the same DDI, received it, attended transfer and the variable has been wiped.</p>
  
  <p>Once the extension logic can see the number of the line called, I can easily turn this into the actual number through a quick database lookup.</p>
  
  <p>Can anyone tell me why this happens between an attended and blind transfer?</p>
  
  <p>Can anyone suggest a way to persist this information for that call across the transfer so the newly created channel can see the original information?</p>
  
  <p>I've tried the single underscore and double underscore methods but that doesn't seem to work.</p>
  
  <p>I'm running Asterisk 13.25 at the moment - realise i'm quite behind on this particular person's box but its a complicated setup.  According to the docs 1.6 implemented the underscore variable names.</p>