-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathTimestamp.js
More file actions
27 lines (16 loc) · 752 Bytes
/
Copy pathTimestamp.js
File metadata and controls
27 lines (16 loc) · 752 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// This code is wriiten in Google Apps Script(JavaScript)
// This code adds timestamp to Google Sheets as soon as a change is made to a specified column
function onEdit(e){
const row = e.range.getRow();
const col = e.range.getColumn();
const sheetName = "Sheet1";
if (col === 1 && row > 1 && e.source.getActiveSheet().getName() === "Sheet1"){
const currentDate = new Date();
e.source.getActiveSheet().getRange(row,4).setValue(currentDate);
const name = Session.getActiveUser().getEmail();
e.source.getActiveSheet().getRange(row,5).setValue(name)
if(e.source.getActiveSheet().getRange(row,3).getValue() == ""){
e.source.getActiveSheet().getRange(row,3).setValue(currentDate);
}
}
}