title: Error when returning an array from google script to a function in website
body: <p>When update is called it runs a script called update as you can see here in the following code snipits:</p>
  
  <p>within the HTML:</p>
  
  <pre><code>function updDate(date){
     console.log("update called");
  
        google.script.run.withSuccessHandler(myReturnFunction).updDate(date);
        //Crossover.libTest();
        console.log("crossover should have been called");
  
        }
        function myReturnFunction(garbage){
  
       console.log("Returned:  "+ garbage);
  
         /*for (var i = 0; i &lt; whatGotReturned.length; i++) {
               document.getElementById("field_"+[i]).innerHTML = whatGotReturned[i];
             }*/
           }
  </code></pre>
  
  <p>Within the Google Script:</p>
  
  <pre><code>function updDate(date){
  
    var searchString = date;
    var s2 = SpreadsheetApp.openById("0AnDrS3YbyWoLdC15aktnMTluUkQ3dWhNTFlyQXBPOFE");
    var data = s2.getActiveSheet().getDataRange().getValues();
  
  
    var k;
  
  
    for (var i in data) {
      for (var j in data[i]) {
        if (i !=0){
          if(data[i][j] != ""){
            if(j == 4){
              var ssDate = Utilities.formatDate(data[i][j], "GMT", "MM/dd/yyyy");
  
              if(date == ssDate){
                k= i
                var p = data[i].length
  
  
              }//conclude if
            }//conclude if (j==4)
  
          }//conclude if(data[i][j] != "")
          }//conclude if (data[i][j] != "")
        } //conclude for (var j in data[i])
      }//conclude for (var i in data)
  
  
    //Logger.log("K is:  "+k)
    var valuesToSnd = new Array();
  
    var q = 1
    while (q &lt;= p){
  
  
      //if(data[k][q] !=""){
        valuesToSnd[q] = data[k][q];
      //document.getElementById("field_"+[q]).innerHTML = data[k][q];
  
      //}
  
  
      q++
  
    }
    Logger.log("Values to Send:  "+valuesToSnd);
        return valuesToSnd;
  
  
    }
  </code></pre>
  
  <p>The google script will log the array like it should:</p>
  
  <blockquote>
    <p>[14-08-26 08:47:03:950 EDT] Values to Send:  ,BABS only at
    AFM,,BABS,Fri Aug 08 2014 00:00:00 GMT-0400 (EDT),No Unload
    Necissary,<a href="https://docs.google.com/forms/d/1yBiXtjTpXs85BNs5Lsj0zGQtDtxghm6-e2lRebB4saw/viewform?edit=ChM1NzYwNDkwNTY0Nzg2NjY5MTI4EJKj-OTR3ejNhwE,,https://docs.google.com/document/d/15f2HjJjNTxjlLZOkB2BOe8nY9ZlImmaAaSSnhViAa4I/edit,,Thu" rel="nofollow">https://docs.google.com/forms/d/1yBiXtjTpXs85BNs5Lsj0zGQtDtxghm6-e2lRebB4saw/viewform?edit=ChM1NzYwNDkwNTY0Nzg2NjY5MTI4EJKj-OTR3ejNhwE,,https://docs.google.com/document/d/15f2HjJjNTxjlLZOkB2BOe8nY9ZlImmaAaSSnhViAa4I/edit,,Thu</a>
    Aug 07 2014 15:30:00 GMT-0400 (EDT),Sat Dec 30 1899 14:30:00 GMT-0500
    (EST),Sat Dec 30 1899 15:00:00 GMT-0500 (EST),Sat Dec 30 1899 18:45:00
    GMT-0500 (EST),5 Ton 35 ,No,No,,,,,All Singers,Not
    needed,,Needed,Needed,,,,<a href="https://docs.google.com/spreadsheet/ccc?key=0AnDrS3YbyWoLdDdSel9RVVNVMGhDakwxMmdueGc4WGc&amp;usp=drive_web#gid=4,,No,AFM,https://www.mediafire.com/folder/dp788cvtbexsf/" rel="nofollow">https://docs.google.com/spreadsheet/ccc?key=0AnDrS3YbyWoLdDdSel9RVVNVMGhDakwxMmdueGc4WGc&amp;usp=drive_web#gid=4,,No,AFM,https://www.mediafire.com/folder/dp788cvtbexsf/</a>,</p>
  </blockquote>
  
  <p>Somewhere after the script runs the console returns this error: </p>
  
  <blockquote>
    <p>Uncaught ScriptError: The script completed but the returned value is
    not a supported return type.</p>
  </blockquote>
  
  <p>Is there something wrong with the code or is there a character in the array that the function doesn't "like"? </p>
  
  <p>Thanks,</p>
  
  <p>Loren</p>
  
  <p>This works:</p>
  
  <pre><code>  var valuesToSnd = new Array();
  
    var q = 0
    while (q &lt;= p){
  
      //if(q!=0){
  
        if(data[k][q] !=""){
  
          if (q==11){
            var trudeptTime = Utilities.formatDate(data[k][q], Session.getScriptTimeZone(), "HH:mm");
            valuesToSnd[q] = trudeptTime;
          } 
          else if(q==12){
  
            var lITime = Utilities.formatDate(data[k][q], Session.getScriptTimeZone(), "HH:mm");
            valuesToSnd[q] = lITime;
          }
          else if (q==13){
            var sCTime = Utilities.formatDate(data[k][q], Session.getScriptTimeZone(), "HH:mm");
            valuesToSnd[q] = sCTime;
          }else{
  
        valuesToSnd[q] = q+ ":  "+ data[k][q];
          }
  
  
        }else{
  
          //valuesToSnd[q]= q + "Nothing";
        }      
      /*}else{
        valuesToSnd[q]= q+ ":  "+ data[k][q];
      }*/
      q++
  
    }
    Logger.log("Values to Send:  "+valuesToSnd);
    return valuesToSnd;
  
    }
  </code></pre>
  
  <p>This doesn't:</p>
  
  <pre><code>  var valuesToSnd = new Array();
  
    var q = 0
    while (q &lt;= p){
  
      //if(q!=0){
  
        if(data[k][q] !=""){
  
          if (q==11){
            var trudeptTime = Utilities.formatDate(data[k][q], Session.getScriptTimeZone(), "HH:mm");
            valuesToSnd[q] = trudeptTime;
          } 
          else if(q==12){
  
            var lITime = Utilities.formatDate(data[k][q], Session.getScriptTimeZone(), "HH:mm");
            valuesToSnd[q] = lITime;
          }
          else if (q==13){
            var sCTime = Utilities.formatDate(data[k][q], Session.getScriptTimeZone(), "HH:mm");
            valuesToSnd[q] = sCTime;
          }else{
  
        valuesToSnd[q] = data[k][q];
          }
  
  
        }else{
  
          //valuesToSnd[q]= q + "Nothing";
        }      
      /*}else{
        valuesToSnd[q]= q+ ":  "+ data[k][q];
      }*/
      q++
  
    }
    Logger.log("Values to Send:  "+valuesToSnd);
    return valuesToSnd;
  
    }
  </code></pre>
  
  <p>Following some comments below here is a log following a tweak or two:</p>
  
  <pre><code>14-08-27 12:51:51:572 EDT] k:  26 q:  0Timestamp data:  Mon Jul 14 2014 11:08:15 GMT-0400 (EDT)
  [14-08-27 12:51:51:573 EDT] k:  26 q:  1Gig Name data:  BABS only at AFM
  [14-08-27 12:51:51:573 EDT] k:  26 q:  2Program Name data:  
  [14-08-27 12:51:51:573 EDT] k:  26 q:  3Groups Involved data:  BABS
  [14-08-27 12:51:51:574 EDT] k:  26 q:  4Gig Date data:  Fri Aug 08 2014 00:00:00 GMT-0400 (EDT)
  [14-08-27 12:51:51:574 EDT] k:  26 q:  5Notes data:  No Unload Necissary
  [14-08-27 12:51:51:574 EDT] k:  26 q:  6Gig Coordination Form Link data:  https://docs.google.com/forms/d/1yBiXtjTpXs85BNs5Lsj0zGQtDtxghm6-e2lRebB4saw/viewform?edit=ChM1NzYwNDkwNTY0Nzg2NjY5MTI4EJKj-OTR3ejNhwE
  [14-08-27 12:51:51:575 EDT] k:  26 q:  7Announcer Name data:  
  [14-08-27 12:51:51:575 EDT] k:  26 q:  8Program Notes Link data:  https://docs.google.com/document/d/15f2HjJjNTxjlLZOkB2BOe8nY9ZlImmaAaSSnhViAa4I/edit
  [14-08-27 12:51:51:575 EDT] k:  26 q:  9Jump to page data:  
  [14-08-27 12:51:51:576 EDT] k:  26 q:  10Truck Load data:  Thu Aug 07 2014 15:30:00 GMT-0400 (EDT)
  [14-08-27 12:51:51:576 EDT] k:  26 q:  11Truck Departure Time data:  Sat Dec 30 1899 14:30:00 GMT-0500 (EST)
  [14-08-27 12:51:51:577 EDT] k:  26 q:  12Load In Time data:  Sat Dec 30 1899 15:00:00 GMT-0500 (EST)
  [14-08-27 12:51:51:578 EDT] k:  26 q:  13Sound Check Time data:  Sat Dec 30 1899 18:45:00 GMT-0500 (EST)
  [14-08-27 12:51:51:579 EDT] k:  26 q:  14Trucks to be used data:  5 Ton 35 
  [14-08-27 12:51:51:579 EDT] k:  26 q:  15LRS Support Required data:  No
  [14-08-27 12:51:51:579 EDT] k:  26 q:  16LRS Request submitted data:  No
  [14-08-27 12:51:51:580 EDT] k:  26 q:  17Date Request submitted to Band VCO/VNCO data:  
  [14-08-27 12:51:51:580 EDT] k:  26 q:  18LRS Confirmation Number data:  
  [14-08-27 12:51:51:581 EDT] k:  26 q:  19Unload Truck data:  
  [14-08-27 12:51:51:581 EDT] k:  26 q:  20Jump to page data:  
  [14-08-27 12:51:51:581 EDT] k:  26 q:  21BABS Crew Members data:  All Singers
  [14-08-27 12:51:51:581 EDT] k:  26 q:  22BABB Crew Members data:  Not needed
  [14-08-27 12:51:51:582 EDT] k:  26 q:  23Jump to page data:  
  [14-08-27 12:51:51:582 EDT] k:  26 q:  24Input List data:  Needed
  [14-08-27 12:51:51:583 EDT] k:  26 q:  25Pack List data:  Needed
  [14-08-27 12:51:51:583 EDT] k:  26 q:  26Pack list Link (If Applicable) data:  
  [14-08-27 12:51:51:583 EDT] k:  26 q:  27Singers Standing arrangment data:  
  [14-08-27 12:51:51:583 EDT] k:  26 q:  28Jump to page data:  
  [14-08-27 12:51:51:584 EDT] k:  26 q:  29Input List Link (if Applicable) data:  https://docs.google.com/spreadsheet/ccc?key=0AnDrS3YbyWoLdDdSel9RVVNVMGhDakwxMmdueGc4WGc&amp;usp=drive_web#gid=4
  [14-08-27 12:51:51:584 EDT] k:  26 q:  30 data:  
  [14-08-27 12:51:51:584 EDT] k:  26 q:  31Singers Stands required data:  No
  [14-08-27 12:51:51:585 EDT] k:  26 q:  32Gig Location data:  AFM
  [14-08-27 12:51:51:585 EDT] k:  26 q:  33Media Link data:  https://www.mediafire.com/folder/dp788cvtbexsf/
  </code></pre>