Function onEdit(e) not working by any mean..

167 views
Skip to first unread message

Xan adu

unread,
Oct 16, 2022, 6:06:35 PM10/16/22
to Google Apps Script Community
Hi, I saw a youtube video of a script working just fine which I replicated for the use of a timestamp in a certain spreadsheet over a certain range.
Here is my script:

function onEdit(e) {
  const ShtName = "Log"
  const ColNb = 7
  var sht = SpreadsheetApp.getActiveSheet().getName()
  var col = e.range.getColumn()
  var row = e.range.getRow()
  var currentDate = new date()

  if(sht === ShtName && col < ColNb + 1 && col > 1 && row > 2) {
    e.source.getActiveSheet().getRange(row, ColNb + 1).setValue(currentDate)
    if(e.source.getActiveSheet().getRange(row, ColNb).getValue() == "") {
      e.source.getActiveSheet().getRange(row, ColNb).setValue(currentDate)
    }
  }
}

- When I try to run the script through Apps Script, it can't access 'e' element
- I don't know how to attach that script to be working on my spreadsheet since it's two distinct app/page I find it so confusing and nothing happen to my spreadsheet.

I would link screenshots of both script and spreadsheet but doesn't seem to be allowed here.

I would like to know either if it's me not connecting the script to my spreadsheet or something.. Because the same script works just fine for a youtuber, is it deprecated or something? I am connected to my google account on every pages.

Andrew Roberts

unread,
Oct 17, 2022, 1:29:37 AM10/17/22
to google-apps-sc...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/d4e7014a-4885-48ca-bcee-81ae7d1d7fe4n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages