function recordScan(e) {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet1'); // Update with your sheet name
const scannedId = e.value; // This assumes the scanned ID is input into a cell
const currentTime = new Date();
const action = determineAction(scannedId); // Custom logic to toggle between Time-In/Time-Out
sheet.appendRow([scannedId, currentTime, action]);
}
function determineAction(id) {
// Logic to decide Time-In or Time-Out (can check the last entry of the same ID)
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet1');
const lastRow = sheet.getLastRow();
const lastAction = sheet.getRange(lastRow, 3).getValue();
return lastAction === 'Time-In' ? 'Time-Out' : 'Time-In';
}