Determine current user in Apps Script

前端 未结 4 1560
深忆病人
深忆病人 2020-12-03 22:55

I\'m trying to identify current user\'s name to make notes of who edited what like this:

  r.setComment(\"Edit at \" + (new Date()) + \" by \" + Session.getA         


        
4条回答
  •  暖寄归人
    2020-12-03 23:29

    I suppose you have this piece of code set to execute inside an onEdit function (or an on edit trigger).

    If you are on a consumer account, Session.getActiveUser().getEmail() will return blank. It will return the email address only when both the author of the script and the user are on the same Google Apps domain.

提交回复
热议问题