title: google.script.run not working: Uncaught InvalidArgumentError: Failed due to illegal value in property: 0
body: <p><a href="https://script.google.com/a/macros/apps.howest.be/s/AKfycbzEer3ZlPP5OMBBylIzdWzEx2GlJEAv55D1vEDbsGA/exec" rel="nofollow">My small form-handling script</a> seems to have somehow broken google.run.script .  I invoke it like this:</p>
  
  <pre><code>google.script.run.withSuccessHandler(worked).verwerkForm(this.parentNode);
  </code></pre>
  
  <p>When running the script here's what i get as an error: </p>
  
  <blockquote>
    <p>Uncaught InvalidArgumentError: Failed due to illegal value in property: 0</p>
  </blockquote>
  
  <p>Previous versions were running fine and i have no clue what it is i did that broke the code.  Google apps script is, to put it mildly very annoying when it comes to errormessages or documentation.  If anyone can help that'd be great!</p>
  
  <p>For reference i've also submitted an issue here: <a href="https://code.google.com/p/google-apps-script-issues/issues/detail?can=2&amp;start=0&amp;num=100&amp;q=&amp;colspec=Stars%20Opened%20ID%20Type%20Status%20Summary%20Component%20Owner&amp;groupby=&amp;sort=&amp;id=4650" rel="nofollow">google script issue report</a></p>
  
  <p>The index file i'm using:</p>
  
  <pre><code>&gt; &lt;?!= include('Stylesheet'); ?&gt; &lt;div class="container"&gt;    &lt;h1
  &gt; id="PageHeader"&gt;World Basketball Coaches Community -
  &gt; Inschrijving/Application&lt;/h1&gt;    &lt;img
  &gt; src="https://drive.google.com/a/apps.howest.be/uc?export=view&amp;id=0B1m3_53fwZc8cmdKYjJvakk3WDA"/&gt;
  &gt; &lt;p id="required"&gt;* required&lt;/p&gt;    &lt;form id="form"&gt;
  &gt;       &lt;div class="special"&gt;
  &gt;          &lt;p&gt;Aanhef &lt;span class="required"&gt;*&lt;/span&gt;&lt;/p&gt;
  &gt;          &lt;label&gt;&lt;input type="radio" name="voorvoegsel" value="Mr" checked /&gt;Mr&lt;/label&gt;
  &gt;          &lt;label&gt;&lt;input type="radio" name="voorvoegsel" value="Mrs"/&gt;Mrs&lt;/label&gt;
  &gt;          &lt;label&gt;&lt;input type="radio" name="voorvoegsel" value="Miss"/&gt;Miss&lt;/label&gt;
  &gt;          &lt;span&gt;&lt;/span&gt;
  &gt;       &lt;/div&gt;
  &gt;       &lt;div&gt;
  &gt;          &lt;label for="voornaam"&gt;Voornaam /Prénom /First name &lt;span class="required"&gt;*&lt;/span&gt;&lt;/label&gt;
  &gt;          &lt;input type="text" name="voornaam" id="voornaam" placeholder="Voornaam"/&gt;
  &gt;          &lt;span class="fout"&gt;&lt;/span&gt;
  &gt;       &lt;/div&gt;
  &gt;       &lt;div&gt;
  &gt;          &lt;label for="naam"&gt;Naam /Nom /Name &lt;span class="required"&gt;*&lt;/span&gt;&lt;/label&gt;
  &gt;          &lt;input type="text" name="naam" id="naam" placeholder="Naam"/&gt;
  &gt;          &lt;span class="fout"&gt;&lt;/span&gt;
  &gt;       &lt;/div&gt;
  &gt;       &lt;div&gt;
  &gt;          &lt;label for="geboortedatum"&gt;Geboortedatum/ Date de naissance/ Date of birth &lt;span class="required"&gt;*&lt;/span&gt;&lt;/label&gt;
  &gt;          &lt;input type="date" name="geboortedatum" id="geboortedatum"/&gt;
  &gt;          &lt;span class="fout"&gt;&lt;/span&gt;
  &gt;       &lt;/div&gt;
  &gt;       &lt;div&gt;
  &gt;          &lt;label for="nationaliteit"&gt;Nationaliteit / Nationalité / Nationaliteit &lt;span class="required"&gt;*&lt;/span&gt;&lt;/label&gt;
  &gt;          &lt;input type="text" name="nationaliteit" id="nationaliteit" placeholder="Nationaliteit"/&gt;
  &gt;          &lt;span class="fout"&gt;&lt;/span&gt;
  &gt;       &lt;/div&gt;
  &gt;       &lt;div&gt;
  &gt;          &lt;label for="stad"&gt;Stad / Ville / City &lt;span class="required"&gt;*&lt;/span&gt;&lt;/label&gt;
  &gt;          &lt;input type="text" name="stad" id="stad" placeholder="Stad"/&gt;
  &gt;          &lt;span class="fout"&gt;&lt;/span&gt;
  &gt;       &lt;/div&gt;
  &gt;       &lt;div&gt;
  &gt;          &lt;label for="land"&gt;Land / Pays / Country &lt;span class="required"&gt;*&lt;/span&gt;&lt;/label&gt;
  &gt;          &lt;input type="text" name="land" id="land" placeholder="Land"/&gt;
  &gt;          &lt;span class="fout"&gt;&lt;/span&gt;
  &gt;       &lt;/div&gt;
  &gt;       &lt;div&gt;
  &gt;          &lt;label for="opleiding"&gt;Opleiding/ Education &lt;span class="required"&gt;*&lt;/span&gt;&lt;/label&gt;
  &gt;          &lt;select name="opleiding" id="opleiding" &gt;
  &gt;             &lt;option value=" "&gt;&lt;/option&gt;
  &gt;             &lt;option value="secondary school"&gt;Secondary school&lt;/option&gt;
  &gt;             &lt;option value="high school"&gt;High school &lt;/option&gt;
  &gt;             &lt;option value="bachelor"&gt;Bachelor&lt;/option&gt;
  &gt;             &lt;option value="master"&gt;Master&lt;/option&gt;
  &gt;             &lt;option value="university"&gt;University&lt;/option&gt;
  &gt;          &lt;/select&gt;
  &gt;          &lt;span class="fout"&gt;&lt;/span&gt;
  &gt;       &lt;/div&gt;
  &gt;       &lt;div&gt;
  &gt;          &lt;label for="gsm"&gt;Gsm &lt;span class="required"&gt;*&lt;/span&gt;&lt;/label&gt;
  &gt;          &lt;input type="text" name="gsm" id="gsm" placeholder="+32 000 00 00 00"/&gt;
  &gt;          &lt;span class="fout"&gt;&lt;/span&gt;
  &gt;       &lt;/div&gt;
  &gt;       &lt;div&gt;
  &gt;          &lt;label for="email"&gt;E-mail &lt;span class="required"&gt;*&lt;/span&gt;&lt;/label&gt;
  &gt;          &lt;input type="email" name="email" id="email" placeholder="someone@example.com"/&gt;
  &gt;          &lt;span class="fout"&gt;&lt;/span&gt;
  &gt;       &lt;/div&gt;
  &gt;       &lt;div&gt;
  &gt;          &lt;label for="passport"&gt;Upload passport or ID copy (PDF or JPEG) &lt;span class="required"&gt;*&lt;/span&gt;&lt;/label&gt;
  &gt;          &lt;input type="file" name="passport" accept="image/jpeg,application/pdf" id="passport"&gt;
  &gt;          &lt;span class="fout"&gt;&lt;/span&gt;
  &gt;       &lt;/div&gt;  
  &gt;       &lt;div&gt;
  &gt;          &lt;label for="color_passport"&gt;Upload color passport size photo (JPEG)&lt;span class="required"&gt;*&lt;/span&gt;&lt;/label&gt;
  &gt;          &lt;input type="file" name="pic" accept="image/jpeg" id="color_passport"&gt;
  &gt;          &lt;span class="fout"&gt;&lt;/span&gt;
  &gt;       &lt;/div&gt;
  &gt;       &lt;div class="permission"&gt;
  &gt;          &lt;label for="akkoord"&gt;
  &gt;             Ik geef mijn akkoord om deze gegevens aan FIBA over te maken in het kader van de "World Basketball Coaches Community". 
  &gt;             Je donne mon accord pour le transfert de mes données à la FIBA dans le cadre du projet "World Basketball Coaches Community"
  &gt; &lt;span class="required"&gt;*&lt;/span&gt;
  &gt;          &lt;/label&gt;
  &gt;          &lt;section id="checkPermission"&gt;&lt;input type="checkbox" value="ja" id="akkoord"/&gt; Ik ben akkoord&lt;/section&gt; 
  &gt;          &lt;span class="fout"&gt;&lt;/span&gt;
  &gt;       &lt;/div&gt;
  &gt;       &lt;div&gt;
  &gt;          &lt;label&gt;&lt;/label&gt;
  &gt;          &lt;input type="button" value="Submit" onclick="submit()"/&gt;
  &gt;       &lt;/div&gt;    &lt;/form&gt; &lt;/div&gt; &lt;div id="result" class='hide'&gt;
  &gt;     &lt;/div&gt; &lt;?!= include('testJavascript'); ?&gt;
  </code></pre>
  
  <p>TestJavascript i'm using: </p>
  
  <pre><code>&lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  function submit() {
        google.script.run.withSuccessHandler(worked).verwerkForm(this.parentNode);
  }
  
  function worked() {
     $(".container").remove();
     $("#result").html('&lt;h1&gt;Dank je uw registratie is een succes!&lt;/h1&gt;').removeClass('hide');
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>and the css:</p>
  
  <pre><code>&lt;style&gt;
  body {
     font-family: Verdana,Arial,sans-serif;
     background-image: -webkit-gradient(
        linear,
        left top,
        left bottom,
        color-stop(0.08, #0D2C91),
        color-stop(0.76, #0788B3)
     );
     background-image: -o-linear-gradient(bottom, #0D2C91 8%, #0788B3 76%);
     background-image: -moz-linear-gradient(bottom, #0D2C91 8%, #0788B3 76%);
     background-image: -webkit-linear-gradient(bottom, #0D2C91 8%, #0788B3 76%);
     background-image: -ms-linear-gradient(bottom, #0D2C91 8%, #0788B3 76%);
     background-image: linear-gradient(to bottom, #0D2C91 8%, #0788B3 76%);
  }
  
  h1#PageHeader {
     margin-bottom:10px;
  }
  
  .container {
     margin: 0 auto;
     width: 80%;
     border-left: 1px solid blue;
     border-right: 1px solid blue;
     background: white;
     padding: 10px 10px;
     text-align:center;
  }
  
  .container form{
     display:inline-block;
  }
  
  .hide{
     display: none;
  }
  
  h1 {
     margin: 0 auto;
     display: block;
  }
  
  img {
     width: 20%;
     margin: 0 auto;
     display: block;
  }
  
  .required {
     color: #ff4444;
     font-weight: 400;
  }
  
  span.fout {
     display:block;
     color : #ff4444;
     margin-left: 36%;
  }
  
  input.fout {
     color : #ff4444;
     border: 1px solid red !important;
  }
  
  form {
     width:80%;
     text-align:left;
  }
  
  form div {
     margin: 10px 0;
     display: block;
  }
  
  form div label {
     box-sizing: border-box;
     display: inline-block;
     padding: 5px;
     width: 35%;
     font-weight: 800;
     font-family: Calibri;
  }
  
  input, select {
     display: inline-block;
     width: 50%;
  }
  
  input[type="text"], input[type="date"], input[type="email"], #opleiding {
     padding: 4px;
     font-size: 14px;
     line-height: 1.42857143;
     color: #555;
     background-color: #fff;
     background-image: none;
     border: 1px solid #ccc;
     border-radius: 4px;
     box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
  }
  
  #opleiding {
     width: 50.8%;
  }
  
  input[type="text"], input[type="date"], input[type="email"]{
     height: 20px;
  }
  
  select{
     height:29px;
  }
  
  .special p {
     display: inline-block;
     padding: 5px;
     width: 32%;
     font-weight: 800;
  }
  
  .special label {
     width: 10%;
     font-weight: 400;
     display: inline-block;
  }
  
  #checkPermission {
     font-family: Calibri;
     font-weight:normal;
     font-size: 16px;
     display: inline-block;
  }
  
  .permission label {
  
  }
  
  input[type="checkbox"]{
     width: 20px;
  }
  
  input:focus {
     border :1px solid blue;
  }
  
  input[type="button"] {
     color: #fff;
     background-color: #428bca;
     border-color: #357ebd;
     display: inline-block;
     padding: 6px 12px;
     margin-bottom: 0;
     font-size: 14px;
     font-weight: 400;
     line-height: 1.42857143;
     text-align: center;
     white-space: nowrap;
     vertical-align: middle;
     cursor: pointer;
     -webkit-user-select: none;
     -moz-user-select: none;
     -ms-user-select: none;
     user-select: none;
     background-image: none;
     border: 1px solid transparent;
     border-radius: 4px;
  }
  
  #required {
     color: #ff4444;
  }
  &lt;/style&gt;
  </code></pre>
  
  <p>The VerwerkForm function: </p>
  
  <pre><code> function verwerkForm(e){
     //check of alle input correct is
     var statusObject = checkInput(e);
     if(!statusObject.inOrde){
       Logger.log("serversidecheck mislukt"); 
       return false;
  //     throw Error("De input is niet correct.  Volgende fouten werden gevonden: " + statusObject.foutboodschappen);
     }
  
     //sla de files in variabelen op en stel direct ook hun naam correct in
     var fileBlobP = doeSetName(e, e.passport, "_passport");
     var fileBlobPic = doeSetName(e, e.pic, "_passport_in_color");
  
     //creating files
     var docPass = DocsList.getFolderById(docP).createFile(fileBlobP);
     var docColorPass = DocsList.getFolderById(docPic).createFile(fileBlobPic);
  
     //maak gegevens om toe te voegen klaar, open dan de spreadsheet en voeg de rij met gegevens toe
     var rijGegevens = [e.voorvoegsel, e.voornaam, e.naam, e.geboorteDatum, e.nationaliteit, e.stad, e.land, e.opleiding, e.gsm, e.email, docPass.getUrl(), docColorPass.getUrl(), new Date()];
     SpreadsheetApp.openById(idSpreadsheet).getActiveSheet().appendRow(rijGegevens);
  }
  </code></pre>
  
  <p><strong>SOLUTION</strong>
  The error turned out to be because i forgot to include a return statement for the successful case in my process form method.  A simple "return ok" at the end was enough to alleviate the problem.</p>