I have two sheets, one is a form responses, the other is with unique work codes. When there is a form submit, I would like to copy and paste the time stamp of last work code in sheet "timedata" in column D where workcode matches. I also would like to do the same thing for the STATUS; copy the status from the answer and paste to sheet "timedata" in column E where the work code matches. Here is my file: https://docs.google.com/spreadsheets/d/1h2_tdStLOGSEtBToXKeb6FGCcVRhokyr7KRIv4uRgm4/edit?usp=sharing
I have a script as following but not sure how to continue;
function lastName() {
var wb = SpreadsheetApp.getActiveSpreadsheet();
var ss1 = wb.getSheets()[0];
var ui = SpreadsheetApp.getUi();
var lr = ss1.getLastRow();
var lc = ss1.getLastColumn();
var dl = ss1.getRange(lr, lc);
var cl = ss1.getRange(lr, lc - 1);
var bl = ss1.getRange(lr, lc - 2);
var al = ss1.getRange(lr, lc - 3);
var ss2 = wb.getSheetByName('timedata');
var mfns = ss2.getRange("A:A").getValues();
var i = 1;
mfns.forEach(function(eachmfns) {
if (cl.getValue() == mfns) {
var dataRange = ss2.getRange(2, 1, 20, 5);
var ss2 = wb.getSheetByName('timedata');
dataRange = ss2.getRange(2 + i, 1 + 3);
dataRange.setValue(al);
i++; //to get the next row
}});
}
I would appreiate if anyone help me until this phase. If I can come until this point I believe I can calculate between the START time and STOP response time of a work so update TOTAL work time.
Thank you in advance.
Edit SOLUTION: The link to my file works, Form is not available but the script works when you run it. Please copy it your gDrive and try it out!