0
votes

I looking for script, that will create audit log in another sheet. In this log it should be:

1)Time stamp 2)User who edited cell 3)The value of the edited cell

I tryed many of tutorial, but I am really new in this and little lost.

1
Sharing your research helps everyone. Tell us what you've tried and why it didn’t meet your needs. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer! See also: How to Ask - pciunkiewicz

1 Answers

1
votes

This script will log all activities in the sheet "Logging"

function onEdit(e) { 
  var email = Session.getEffectiveUser().getEmail();
  var timeZone = Session.getScriptTimeZone();
  var key = Session.getTemporaryActiveUserKey();
  var sName = e.source.getActiveSheet().getSheetName();  
  if(sName !== "Logging") {
    var value;
    var mA1 = e.range.getA1Notation().split(":")[0];       
    if(typeof(e.value) == 'string') {
      var aCell = e.source.getRange(mA1);
      value = aCell.getValue();
      var form = "'" + aCell.getFormula();
    } else {
      value = e.value;      
    }
    var data = [sName, mA1, timeZone, email, key, value, form];
    e.source.getSheetByName("Logging").appendRow(data);
  }
}