function BatteryInspection(e) {
var range = e.range;
var row = range.getRow();
var col = range.getColumn()
var sheet = range.getSheet();
Logger.log("The row is " + row + " and column is " + col + " the sheet is " + sheet);
var sheet, sheetName, colToCapitalize;
var sheetName, colToCapitalize;
colToCapitalize = 2;
sheetName = "FormResponses1";
if (sheet.getName() !== sheetName || e.range.rowStart < 2 || e.range.columnStart !== colToCapitalize || typeof e.value == "object") return;
e.range.setValue(e.value.toUpperCase());
sheet.getRange(row, 10).setFormula("=SUBSTITUTE(B" + row + ",\" \",\"\")");
var cellcopy = sheet.getRange(row, 10);
var cellvalues = cellcopy.getValues();
sheet.getRange(row, 2).setValues(cellvalues);
cellcopy.clearContent();
sheet.getRange(row, 8).setFormula("=VLOOKUP(B" + row + ",LookUpTable!A2:C1001,2,0)");
sheet.getRange(row, 9).setFormula("=VLOOKUP(B" + row + ",LookUpTable!A2:C1001,3,0)");
}
The outcome I want is that the above script runs when a new row of data is added from a google form to the worksheet "FormResponses1". I have created the google form already, and new data is added to the sheet "FormResponses1" when a user submits the form.
Here is a YouTube video of the screen showing the problem I'm having
The above code runs fine and does what I need if I manually add a new value to a cell e.g. if I write "dll 463" in cell "B2" on sheet "FormResponses1".
I have set up a trigger "From spreadsheet - On form submit" for the function onEdit shown above, using Edit - Current project's triggers from the toolbar in the <> script editor view.
The trigger does seem to fire, and if I view the logs after submitting a new response from the form, I can see the log shows the row and column that got edited via the Logger.log line in the code above.
I have added more Logger.log lines to the above code to see how far the script runs when it is triggered by the "From spreadsheet - On form submit" trigger, but no other logs are shown after the row and column edit log.
What makes this more weird for me, is that I could get the trigger to work and run the code yesterday. Albeit, it was only writing in the setFormula lines at the end of the current script, and since then I have added the capitalise column values, and substitute formula to the script.
I have tried: - Deleting and adding a new trigger. - Creating a new version - Deleting form repsonses - Changing the function from onEdit() to onFormSubmit() - Unlinking the spreadsheet and adding a new spreadsheet (with the same sheet names and data) with the script copied into the new spreadsheet script editor and deleting the old spreadsheet.
onFormSubmitThis is an installable trigger that runs when a user responds to a form. As the name suggests you MUST "install" it. Manual installation is easiest doc. I reckon this will fix the problem. - TedinozonEditscript (which is what you have) cannot be triggered by a script event (such as the form submission). ref. Note I stressed a "Simple"onEdit- that's becauseonEditcan also be an Installable trigger. "Simple" triggers have predefined names (onOpen, onEdit, etc) and that's all it takes to create the trigger. But an Installable trigger can have any name at all - it is in the process of installation that one identifies the script name and the event type. - Tedinoz