0
votes

I'm trying to have this script working, but I'm missing something. It should grab data submitted via webform and stored in a spreadsheet that has this script attached, and then perform the following:

*create a new spreadsheet from a pre-formatted and ready-to-use template spreadsheet

*name the new spreadsheet with the data submitted via webform (eg. ID, date and else)

*also, the template as more than one sheet.

function CreateNewSS() {
var ss = SpreadsheetApp.getActiveSpreadsheet(); 
ss.copy("Prefix " + data());  //create the new spreadsheet. 
var data = Range.getCell(0, 0); 
var sheet = ss.getSheetByName('UserSubmittedData'); // sheet feed by web form 
var range = sheet.getRange(1,1); 
}

I'm stuck at this point.

Thanks in advance for any hint.

1
You are ignoring the return value of ss.copyZig Mandel
@ZigMandel: Thank you for noticing that!Gabriel Crivelli

1 Answers

2
votes

You should use the onFormSubmit event to handle this. See Understanding Events section of the documentation for details.

function onFormSubmit(e){

var resp = e.responses; 
var data = resp.getItemResponses()[0].getResponse().toString(); // Change 0 to the question number in the form
var ss = SpreadsheetApp.getActiveSpreadsheet(); 
ss.copy("Prefix " + data());  //create the new spreadsheet. 

}