title: Inserting template text in a Google doc in Google Apps Script
body: <p>I'm trying to create a simple script that prefills a template into a Google doc at the cursor point. I'm a bit stuck on how to add text and list items at the same time. Here is what I have:</p>
  
  <pre><code>function onOpen() {
    var ui = DocumentApp.getUi();
    // Or FormApp or SpreadsheetApp.
    ui.createMenu('Templates')
        .addItem('Insert Template', 'insertTemplate')
        .addToUi();
  
  }
  
  function insertTemplate() {
    var cursor = DocumentApp.getActiveDocument().getCursor();
    if (cursor) {
  
      var element = cursor.insertText("Some Header\n")
      element.setBold(true);
  
      var options = {weekday: 'long', year: 'numeric', month: 'long', day: 'numeric'};
      var today  = new Date();
      dateStr = today.toLocaleDateString("en-US", options) + '\n\n';
  
      var element = cursor.insertText(dateStr);
      element.setBold(true);
  
      var body = DocumentApp.getActiveDocument().getBody();
  
      colors = ["blue", "red", "yellow"]
      colors.forEach( function(color) { 
        body.appendListItem(color + ": ").setGlyphType(DocumentApp.GlyphType.BULLET);
      });
  
    } else {
      DocumentApp.getUi().alert('Cannot find a cursor in the document.');
    }
  }
  </code></pre>
  
  <p>It correctly outputs something like:</p>
  
  <pre><code>Feb 12, 2019
  
  Some Header
  
   * blue
   * red
   * yellow
  </code></pre>
  
  <p>Now I want to append yet another simple line of text after the list but if I do it with cursor, it appends it before the date. How can I find the last position of the last item and insert text after it?</p>