I have a script which creates a pre-filled Google Form from a spreadsheet. I can get the pre-filled URL easily enough and it's working as expected. I'm having a hard time sending the pre-filled form via email. I can get the HTML output using HtmlService
and appending it to the body of the email, but it isn't interactive. I can fill in text fields, but cannot select multiple choice items or submit the form.
Script
// A form is already built...
var logs = ss.getDataRange().getValues();
var formResponse = form.createResponse();
for(var j=0;j<7; j++) {
formItem = items[j+2].asTextItem();
response = formItem.createResponse(weekData[i][j]);
formResponse.withItemResponse(response);
}
var url = formResponse.toPrefilledUrl();
// Mark as sent so it isn't caught in the next trigger
logs.getRange(i+1, logs.getLastColumn()).setValue('sent');
var response = UrlFetchApp.fetch(url);
var htmlBody = HtmlService.createHtmlOutput(response).getContent();
MailApp.sendEmail({
to: "email@address.com",
subject: "Confirm Intern Hours",
htmlBody: htmlBody
});
Any ideas on how to send this as a functional form in an email? If worst comes to worst, I can include a shortened link and have them click out to the live form.