0

I am trying to create a basic attendance workflow where my users will mark attendance in a google spreadsheet. There are separate worksheet for each month. Column E is where users will mark attendance using their gmail login. Column F will set a timestamp in adjacent cell when value was selected in column E.

I have a workable code but that works only for me. When other users of the sheet add or update value in the Column E, the Column F does not set a timestamp.

Update: I have protected Column F so that users can't manually edit the timestamp entry.

This is the piece of code:

function onEdit(e) {
var columnToWatch = 5, columnToStamp = 6; //change all of these to your needs
    if (e.range.columnStart !== columnToWatch ||  !e.value) return;
    e.source.getActiveSheet()
        .getRange(e.range.rowStart, columnToStamp)
        .setValue(new Date());  
}
  • Is there anything above or below this function? – TheMaster Sep 11 '20 at 07:11
  • @TheMaster could that be because of the sheet protection? according to the OP other users can only edit column E. Maybe the sheets are protected. – Marios Sep 11 '20 at 07:25
  • @Marios It could be, but I don't see where OP mentions "others cannot edit anything except E" – TheMaster Sep 11 '20 at 07:34
  • @TheMaster true true. I didn't phrase it correctly. The others might be able to edit only column E. Could OP clarify that for us? – Marios Sep 11 '20 at 07:37
  • Alternatively look into view> executions and show the error. – TheMaster Sep 11 '20 at 07:38
  • No @TheMaster there is nothing above or below this function. – Pulkit Jain Sep 11 '20 at 08:49
  • @Marios Yes I will clarify. No there is range protection for Column F, so that users can't edit the timestamp. Column E doesn't have any sheet or range protection. – Pulkit Jain Sep 11 '20 at 08:52
  • 1
    Then that explains a lot. The onEdit() function updates the timestamp in column F. If other users can't edit column F how is it possible to be able to update the value? Essentially, you can't update the value of a cell if you don't have the permission to edit it. – Marios Sep 11 '20 at 08:55
  • That's true. But how do I restrict users manually updating Timestamp in Column F. I had protected the ranges for the same reason. – Pulkit Jain Sep 11 '20 at 09:32
  • @PulkitJain Read the linked question and answers.. Use installable triggers. Also make sure editors cannot go into the script editor/ edit the script. In which case, they'll easily be able modify your script. – TheMaster Sep 11 '20 at 10:53

0 Answers0