title: updating google spreadsheet B from google spreadsheet A
body: <p>Using a script on spreadsheet A I am trying to update a newly created spreadheet B. The end purpose is to have a CRM sheet (spreadsheet A) from which I can generate invoices (spreadsheet B).</p>
  
  <p>In the script below, all works until the line "sh_Invoice.getRange(5,12).setValue("test");".
  When debugging I can see the objects coming alive, but the setValue() is just not working. I just a blank copy of the copied spreadheet.
  The custom function calls getCustomerData() and copyFileInFolder work fine.</p>
  
  <p>Any suggestions?</p>
  
  <p>Thanks in advance,
  Tom</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>function createNewInvoice () {
    // gets handle on active sheet
    var sh = ss.getActiveSheet();
    // check if active sheet is CRM
    if (sh.getName() != "CRM") {
      showError(messageData.DialogTitle, messageData.Error0);
      return;
    }
    // build customer json table from active row in sheet
    var customer = getCustomerData(sh);
    // copy invoice template
    var f_Invoice = copyFileInFolder(configData.IdInvoiceTmpl);
    var ss_Invoice = SpreadsheetApp.openById(f_Invoice.getId());
    SpreadsheetApp.setActiveSpreadsheet(ss_Invoice);
    ss_Invoice.rename("Factuur 2015-" + configData.invoiceNumber + " (" + customer.name + ")");
    // fill in some data in the new sheet
    var sh_Invoice = ss_Invoice.setActiveSheet(ss_Invoice.getSheets()[0]);
    sh_Invoice.getRange(5,12).setValue("test");
    // set CRM spreadsheet back to active
    SpreadsheetApp.setActiveSpreadsheet(ss);
  
  }</code></pre>
  </div>
  </div>
  </p>