title: How do I enter document ID/template ID into a Google Script in order to autofill a template?
body: <p>Looking to build a Google Script that will insert entries into a document based on certain entries, either from prompts or text fields (ex. what's typed as Name replaces each instance of ##name## in the text below.) The closest I've found to what I need is this blog <a href="https://www.makeuseof.com/tag/google-docs-scripts-automate/" rel="nofollow noreferrer">https://www.makeuseof.com/tag/google-docs-scripts-automate/</a>. However, when I go to enter the document ID as instructed, the code results in an error. My code so far is below. I've been replacing each instance of (documentID) with the part after document/d in a Google Doc (10IUD6NDli_DThIO4nGaoTYvtcMgIggcB2Gl5zYN8F3Q) to no avail. I am getting the prompts and able to answer them, but no copy is being saved to my Drive's root folder.</p>
  <pre><code>
  function myFunction() {
    // Display a dialog box for each field you need information for.
    
    var ui = DocumentApp.getUi();
    //var response = ui.prompt('Enter Name', 'Enter sales person's name', ui.ButtonSet.OK);
    var nameResponse = ui.prompt('Enter sales persons name');
    var client1Response = ui.prompt('Enter client 1');
    var sales1Response = ui.prompt('Enter sales 1');
      
    //Make a copy of the template file
    var documentId = DriveApp.getFileById('&lt;my-template-id&gt;').makeCopy().getId();
        
    //Rename the copied file
    DriveApp.getFileById(documentId).setName(nameResponse.getResponseText() + date + ' Sales Report');  
        
    //Get the document body as a variable
    var body = DocumentApp.openById(documentId).getBody();
      
    //Insert the entries into the document
    body.replaceText('##name##', nameResponse.getResponseText());
    body.replaceText('##client1##', client1Response.getResponseText());
    body.replaceText('##sales1##', sales1Response.getResponseText()); 
  </code></pre>