title: Saving an array globally
body: <p><strong>What I'm trying to achieve</strong></p>
  
  <p>I have a spreadsheet with 2 sheets <code>A</code> &amp; <code>B</code>.</p>
  
  <ul>
  <li><p><code>A</code> has 2 columns - Name, Amount (Master List)</p></li>
  <li><p><code>B</code> has 4 columns - Name, Amount, X, Y (Transaction List)</p></li>
  </ul>
  
  <p><em>Name</em> column of <code>Sheet B</code> references <em>Name</em> column of <code>Sheet A</code> for data. Whenever a name is selected, I want to populate Amount column in <code>B</code> with Amount in column of <code>sheet A</code> as a placeholder which users can override. For this, I plan to load the <code>Sheet A</code> data in an array (available Globally) so that in <code>onEdit(e)</code> I can refer that array instead of accessing <code>Sheet B</code>.</p>
  
  <p>But the options I could find - <code>CacheService</code> and <code>PropertyService</code> - save only string values. But I want to have:</p>
  
  
  
  <pre class="lang-js prettyprint-override"><code>var myGlobalArray = [];
  
  function on init(){
      //iterate and fill the array such that it has following output
      //myGlobalArray[Name1] = 1
      //myGlobalArray[Name2] = 2
      //myGlobalArray[Name3] = 3
  }
  
  function onEdit(e){ 
    //if selected value is name1, populate myGolbalArray[Name1] value in Amount
  }
  </code></pre>
  
  <p><strong>Question</strong>
  Where &amp; how to define myGlobalArray?</p>
  
  <p>I tried to use cache service with <code>JSON.Stringify</code> and <code>JSON.parse</code> but the array is empty in <code>onEdit</code>.</p>