title: How do I email a copied doc from a google form?
body: <p>I am working with 3 documents:</p>
  <ul>
  <li>[This google form][1]</li>
  <li>[This spreadsheet of form responses][2]</li>
  <li>[This google doc template][3]</li>
  </ul>
  <p>When someone submits the form, I would like the following workflow automated:</p>
  <ol>
  <li>The template is copied into this folder with some items copied from the form into the new copied doc. (My script is currently functioning and getting that done)</li>
  <li>The person who submits the form is owner of the new document &amp; receives an email alert for their new document (Cannot figure this part out.  I have tried the addEditor method, but I am getting an error)</li>
  <li>The URL of the new document copy is added to column L of the form responses spreadsheet so the new documents are indexed and easily accessible.</li>
  </ol>
  <p>Here is the script I am using:</p>
  <pre><code>    function autoFillGoogleDocFromForm(e) {
    //e.values is an array of form values
    var timestamp = e.values[0];
    var email = e.values[1];
    var firstName = e.values[2];
    var lastName = e.values[3];
    var crossroadsEmail = e.values[4];
    const building = e.values[5];
    var grade = e.values[6];
    var subject = e.values[7];
    var course = e.values[8];
    var title = e.values[9];
    var length = e.values[10];
    
    
    //define variables in both sheets
    var formresponses = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Form Responses 1');
    var lastrowformresponses = formresponses.getLastRow();
    var formresponsesrange = formresponses.getRange(1, 1, lastrowformresponses, 12);
    
    //file is the template file, and you get it by ID
    var file = DriveApp.getFileById('1GKmUZCN8Maq74UWBFNLscd1xh1GKDMvD2tpZWhI9Ou8'); 
    
    //We can make a copy of the template, name it, and optionally tell it what folder to live in
    //file.makeCopy will return a Google Drive file object
    var folder = DriveApp.getFolderById('1q9nfUtJ-iI00etxLSHJKsBJ7cQR-7brC')
    var copy = file.makeCopy(subject + ',' + grade + ',' + title , folder); 
    
    //Once we've got the new file created, we need to open it as a document by using its ID
    var doc = DocumentApp.openById(copy.getId()); 
    
    //Since everything we need to change is in the body, we need to get that
    var body = doc.getBody(); 
    
    //Then we call all of our replaceText methods
    body.replaceText('{{First Name}}', firstName); 
    body.replaceText('{{Last Name}}', lastName);  
    body.replaceText('{{Title of Unit}}', title); 
    body.replaceText('{{Subject}}', subject); 
    body.replaceText('{{Grade}}', grade);  
    body.replaceText('{{Name of Course}}', course); 
    body.replaceText('{{Length of Unit}}', length);  
    
    // we save and close the document to persist our changes
    var url = doc.getUrl();
    doc.saveAndClose();
    
    //We add the teacher as the editor
    var editorEmail = formresponsesrange.getCell(lastrowformresponses, 2);
    DocumentApp.openByUrl(url).addEditor(editorEmail);
      
    
  
  }
  </code></pre>