title: Google Scripts Returning Undefined
body: <p>My goal is to create a portal where I can accept file uploads to a folder named after the person submitting, then log their name to a spreadsheet.</p>
  
  <p>The function “uploadFiles()” uploads and organizes the uploads in a new file just fine. However when I run the function “saveToSpreadsheet()” it publishes an “undefined” instead of pulling any form data from my spreadsheet.</p>
  
  <p>I am fairly new JavaScript and this is my first project working within Google Apps Script, please pardon my being a novice when I ask: what is causing this lack of communication between functions? </p>
  
  <p><strong>HTML Form</strong></p>
  
  <pre><code>&lt;form id="myForm"&gt;
  &lt;input type="text" name="artistName" placeholder="First and last name"&gt;
  &lt;input type="text" name="artTitle" placeholder="Title of submission"&gt;
  &lt;input type="text" name="yearProduced" placeholder="Year created"&gt;
  &lt;input type="text" name="medium" placeholder="Medium"&gt;
  
  &lt;input type="file" name="myFile"&gt;
  &lt;input type="submit" value="Upload File" 
  onclick="this.value='Uploading..';
  google.script.run.withSuccessHandler(fileUploaded)
  .uploadFiles(this.parentNode);
  return false;"&gt;
  &lt;/form&gt;
  
  &lt;div id="output"&gt;&lt;/div&gt;
  
  &lt;script&gt;
      function fileUploaded(status) {
          document.getElementById('myForm').style.display = 'none';
          document.getElementById('output').innerHTML = status;
      }
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>Google Script File</strong></p>
  
  <pre><code>function doGet(e) {
    return HtmlService.createHtmlOutputFromFile('form.html');
  }
  
  function uploadFiles(form) {
  
    try {
      var dropbox = form.artistName.replace(/\s+/g, '-').toLowerCase();
      var folder, folders = DriveApp.getFoldersByName(dropbox);
      var artistName = form.artistName;
      var artTitle = form.artTitle;
      var yearProduced = form.yearProduced;
      var medium = form.medium;
  
  
      if (folders.hasNext()) {
        folder = folders.next();
      } else {
        folder = DriveApp.createFolder(dropbox);
      }
  
      var blob = form.myFile;    
      var file = folder.createFile(blob);    
      file.setDescription("Created by " + artistName + ". " + artTitle + " in " + yearProduced + " in a medium of " + medium);
  
      return "File uploaded successfully. Thanks, " + artistName + "!";
  
      saveToSpreadsheet(artistName);
  }    
      catch (error) {
  
      return error.toString();
    }
  }
  
  function saveToSpreadsheet(data) {
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var sheet = ss.getSheets()[0];
  
    var j = sheet.getLastRow();
  
    var cell = sheet.getRange(1, 1);
    var cellValue = sheet.getSheetValues(1, 1, 1, 1);
  
    cell.setValue(data);
  
    Logger.log(data);
  }
  </code></pre>
  
  <p><strong>Edit (this ended up solving my problem)</strong></p>
  
  <pre><code>function doGet(e) {
    return HtmlService.createHtmlOutputFromFile('form.html');
  }
  
  function uploadFiles(form) {
  
    try {
      var dropbox = form.artistName.replace(/\s+/g, '-').toLowerCase();
      var folder, folders = DriveApp.getFoldersByName(dropbox);
      var artistName = form.artistName;
      var artTitle = form.artTitle;
      var yearProduced = form.yearProduced;
      var medium = form.medium;
      var xyz = saveToSpreadsheet(artistName);
  
  
      if (folders.hasNext()) {
        folder = folders.next();
      } else {
        folder = DriveApp.createFolder(dropbox);
      }
  
      var blob = form.myFile;    
      var file = folder.createFile(blob);    
      file.setDescription("Created by " + artistName + ". " + artTitle + " in " + yearProduced + " in a medium of " + medium);
  
      return "File uploaded successfully. Thanks, " + artistName + "!";
  
      saveToSpreadsheet(xyz);
  }    
      catch (error) {
  
      return error.toString();
    }
  }
  
  function saveToSpreadsheet(data) {
    var ss = SpreadsheetApp.openById('mysheetID');
    var sheet = ss.getSheets()[0];
  
    var j = sheet.getLastRow();
  
    var cell = sheet.getRange(1, 1);
    var cellValue = sheet.getSheetValues(1, 1, 1, 1);
  
    cell.setValue(data);
  
    Logger.log(data);
  }
  </code></pre>