Current Setup
I have a Google Form that feeds data into a spreadsheet. When someone submits the form, my Apps Script automatically creates a new Google Doc for each submission. This works fine but creates too many separate documents.
What I Want to Achieve
Instead of generating individual docs for every form response, I want to append all submissions from the same person into one master document. This way each team member would have just one doc containing all their entries instead of dozens scattered around.
My Current Code
function processFormData(event) {
var clientName = event.values[1];
var submissionDate = event.values[2];
var status = event.values[3];
var category = event.values[4];
var userComments = event.values[5];
var feedback = event.values[6];
var additionalInfo = event.values[7];
var staffMember = event.values[8];
var managerName = event.values[9];
var sourceTemplate = DriveApp.getFileById("template-id-here");
var destinationFolder = DriveApp.getFolderById("folder-id-here");
var newCopy = sourceTemplate.makeCopy(clientName, destinationFolder);
var document = DocumentApp.openById(newCopy.getId());
var documentBody = document.getBody();
documentBody.replaceText("{{Client Name}}", clientName);
documentBody.replaceText("{{Submission Date}}", submissionDate);
documentBody.replaceText("{{Status}}", status);
documentBody.replaceText("{{Category}}", category);
documentBody.replaceText("{{User Comments}}", userComments);
documentBody.replaceText("{{Feedback}}", feedback);
documentBody.replaceText("{{Additional Info}}", additionalInfo);
documentBody.replaceText("{{Staff Member}}", staffMember);
documentBody.replaceText("{{Manager Name}}", managerName);
document.saveAndClose();
}
My Question
How can I modify this to append new form submissions to an existing document instead of creating new ones? I’m thinking about copying the content from the newly created doc into a master doc and then deleting the temporary one. Is this approach feasible with Apps Script?