function onFormSubmit(event) {
try {
// event is the event object { range: {}, namedValues: {}, values: [], authMode: enum, triggerUid: uid }
let parent = e.range.getSheet().getParent(); // parent spreadsheet
let sheetB = parent.getSheetByName("Sheet B");
// get some table of hours limit (total unknown to me what that is)
let hoursLimt = parent.getSheetByName("Some sheet").getRange(1,1,10,1).getValues();
// "respondant" is in column A of the hoursLimit table and event.values[0]
// look up respondant in the lookup table
let respondant = hoursLimit.find( row => row[0] === event.values[0] );
if( respondant === undefined ) throw "Respondant ["+event.values[0]+"] not found";
sheetB.appendRow(event.values);
SpreadsheetApp.flush(); // insure new row has been added
// assume respondent[1] is the limit (H) and event.values[3] (D) is the form value
// getRange(sheetB.getLastRow(),7) is column G of the new row
sheetB.getRange(sheetB.getLastRow(),7).setValue(respondant[1]-event.values[3]);
}
catch(err) {
console.log(err);
}
}
Is there any way I can modify the script that I currently have and set it up so the lookup value is triggered on each row only with the form submission so that the value previously entered will no longer changed with a new form submission