Reputation: 1147
I have a script that records a log of all changes in a spreadsheet:
function onEdit() {
var timestamp = new Date();
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var cell = sheet.getActiveCell();
var user = Session.getActiveUser();
var columnLabel = sheet.getRange(1, cell.getColumn()).getValue();
var changelogSheet = ss.getSheetByName("Changelog");
changelogSheet.appendRow([timestamp, cell.getA1Notation(), columnLabel, cell.getValue(), user.getEmail()]);
}
This codes beautifully creates a row of data in "Changelog" sheet every time there is an edit on "Sheet1". It tells you the date and time, the cell where it was edited, the contents of edit and user who edited it.
My issue is that "Sheet1" is linked to a Google Form that allows users to edit their responses. When users indeed edit their responses on Google Forms, the edit is not registered on my script and there is no log for it.
I presume my script only logs physical edits on the sheet itself.
Is there a way (perhaps using FormApp) to do a similar code that logs every edit on a Google Form?
I really appreciate your help.
Upvotes: 1
Views: 67
Reputation: 11278
You should create a new onFormSubmit trigger that will include similar logic and create a new row in the Google Sheet when a form response is submitted.
Upvotes: 1