I am trying to create a time sheet based on the video here. However, in the video, he sets it up so that it is built for two users, whereas mine is only going to be for one user.
When the user presses the button (really a drawing) to clock in, I want the time to be recorded in cell B2 and the status (in) to be recorded in E2. Just the same, when the user presses the button (another drawing) to clock out, I want the time to be recorded in C2 and the status (Out) to still be recorded in E2. Column D will tell the duration of time passed, which will be used to determine weekly pay.
Here's the script where the "Clock In" button is assigned the "In" Function and the "Clock Out" button is assigned the "Out" Function:
function setValue(cellName, Value) {
SpreadsheetApp.getActiveSpreadsheet().getRange(cellName).setValue(Value);
}
function getValue(cellName) {
return SpreadsheetApp.getActiveSpreadsheet().getRange(cellName).getValue();
}
function getNextRowIn() {
return SpreadsheetApp.getActiveSpreadsheet().getLastRow() - 6;
}
function getNextRowOut() {
return SpreadsheetApp.getActiveSpreadsheet().getLastRow() - 6;
}
function addRecordIn(b) {
var row = getNextRowIn ();
setValue('B' + row, b);
}
function addRecordOut(c) {
var row = getNextRowOut ();
setValue('C' + row, c);
}
function In() {
setValue('E2', 'In');
addRecordIn(new Date());
}
function Out() {
setValue('E2', 'Out');
addRecordOut(new Date());
}
What do I need to do to make this code work out so that each time a user presses "Clock In" it is recorded sequentially in column B, starting at B2. Same for Clock Out in Column C, starting at C2?
Here is a picture of the sheet I'm working with: View it on Imgur.
Here's the way I would do it.
timerecord.html:
code.gs:
This is what the screen looks like:
This view shows the menu