I want Google Apps Script to automatically take any new Form submission (as opposed to everything already on the sheet) and produce a document in which those details are formatted in HTML. A unique document per submission's data. I have already figured out how to create a Trigger that will execute the function upon a form being submitted. I have also figured out how to establish a template document for the script to copy and utilize.
I have included some of the code I've cobbled together from a lot of self-teaching. As you may see, I've gotten as far as being able to manipulate the documents. But, for example, when I try to replace the Management Corp placeholder in the Document, it's replaced with everything in that column rather than the cell of the newest submission. I realize that this is what "u:u" means and so I guess that's the point of my question-- what do I need to do to effectively say "only use the most newest u"? I will duplicate such a method for the other columns as well.
I deeply appreciate your time and help.
function createHTMLchunks() {
const currentSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Form Responses 1");
//DocID (redacted for question)
//SheetID (redacted for question)
//driveFolder (redacted for question)
const docFile = DriveApp.getFileById("(redacted for question)");
const driveFolder = DriveApp.getFolderById("(redacted for question)");
const copyFile = docFile.makeCopy(driveFolder);
const openFile = DocumentApp.openById(copyFile.getId());
const body = openFile.getBody();
body.replaceText("##Management Corp##", NewSubmission('U:U'));
openFile.saveAndClose();
}Here's a method I've used to get the last row number for a column (I don't know if some other columns might be empty; I'm assuming you'll want the last row in your column of interest), if you think that'll do the trick.
--
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/c3632323-2cd2-4a29-be94-e28925ada83eo%40googlegroups.com.
The simplest way to get the row where the submitted values from the form are is to let the google environment variable tell you.
If the createHTMLchunks function is your trigger function, then just do the following:
Function createHTMLchunks (e) {
var row = e.range.getRow(); // row where form submitted data is saved
… rest of code ...
--
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/b05fc708-e8ee-4d4c-98e9-ab26447cc984o%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-community+unsub...@googlegroups.com.
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/c3632323-2cd2-4a29-be94-e28925ada83eo%40googlegroups.com.
--
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/90b70e8a-ea3d-48da-8533-40053d5045aeo%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-community+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/c3632323-2cd2-4a29-be94-e28925ada83eo%40googlegroups.com.
--
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-community+unsub...@googlegroups.com.
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/c3632323-2cd2-4a29-be94-e28925ada83eo%40googlegroups.com.
--
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/90b70e8a-ea3d-48da-8533-40053d5045aeo%40googlegroups.com.
--
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/f3c3e65a-a6f9-42e1-bf0c-b51260bd5b07o%40googlegroups.com.