I just stumbled upon this forum seeking an answer to my own issue. I'm a newbie trying some script in google sheets for a tool I would like to try out.. I literally started it 2 days ago with the aim to track when boxes leave the store room to an office and return. What I've been able to accomplish is capture the office number, time the box leaves and when it returns but now the box column shows "undefined".. please tell me what I'm doing wrong. also, i have assigned only one office button and two box number for testing thus far.
function setValue(cellName, value) {
SpreadsheetApp.getActiveSpreadsheet().getRange(cellName).setValue(value);
}
function getValue(cellName) {
return SpreadsheetApp.getActiveSpreadsheet().getRange(cellName).getValue();
}
function getNextRow() {
return SpreadsheetApp.getActiveSpreadsheet().getLastRow() + 1;
}
function setOFFICE01() {
setValue('F25', 'Office01')
}
function set001() {
setValue('G25', '001')
}
function set002() {
setValue('G25', '002')
}
function addRecord(a, b, c, d) {
var row = getNextRow();
setValue('A' + row, a);
setValue('B' + row, b);
setValue('C' + row, c);
setValue('D' + row, d);
}
function punchIn() {
addRecord(getValue('F25'), new Date(), 'In');
}
function punchOut() {
addRecord(getValue('F25'), new Date(), 'Out');
}