automatically creating a document from information entered into a google sheet

32 views
Skip to first unread message

Jose Saavedra-Estrada

unread,
Apr 30, 2020, 12:16:09 PM4/30/20
to Google Apps Script Community
I'm trying to make a google apps script That will automatically make a new "doc" from new information that is entered into a google "sheet" in the form of a "forms" response. I've very little of where to even start and was wondering if someone had experience doing something similar.

Alan Wells

unread,
Apr 30, 2020, 1:10:56 PM4/30/20
to Google Apps Script Community
Do you have any experience with JavaScript and Apps Script?
What you are describing has multiple steps to it.
Someone may have existing code that does something similar, or some of the process.

Kim Nilsson

unread,
Apr 30, 2020, 3:03:52 PM4/30/20
to Google Apps Script Community
There is an existing addon for that, called autoCrat.

Andrew Roberts

unread,
Apr 30, 2020, 4:20:18 PM4/30/20
to google-apps-sc...@googlegroups.com
This script creates a PDF from a merged Doc, just comment out the line that trashes the GDoc after the PDF is created.
http://www.andrewroberts.net/2014/10/google-apps-script-create-pdf/

On Thu, 30 Apr 2020 at 20:03, 'Kim Nilsson' via Google Apps Script Community <google-apps-sc...@googlegroups.com> wrote:
There is an existing addon for that, called autoCrat.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/4aa46dd4-6275-4fae-a36f-864c70a4ddc7%40googlegroups.com.

Jose Saavedra-Estrada

unread,
May 1, 2020, 9:50:14 AM5/1/20
to Google Apps Script Community
I actually deciphered some code, and for anyone looking to do something similar here is what I used


function autoFillGoogleDocFromForm(e) {
 var timestamp = e.values[0];
  var firstName = e.values[1];
  var lastName = e.values[2];
  var title = e.values[3];
  
  var templateFile = DriveApp.getFileById("1kDdRla8OLjtG7DxY1Zu1VHvE2mZx6qnt-WoUTz7-eyk");
  var templateResponseFolder = DriveApp.getFolderById("14Tp3zsFDr3d4L4vHOKOvH8sR2uSkuPdm");
  
  var copy = templateFile.makeCopy(lastName + ', ' + firstName, templateResponseFolder);
  
  var doc = DocumentApp.openById(copy.getId());
  
  var body = doc.getBody();
  
  body.replaceText("{{FirstName}}", firstName);
  body.replaceText("{{LastName}}", lastName);
  body.replaceText("{{Title}}", title);
  
  doc.saveAndClose();
Reply all
Reply to author
Forward
0 new messages