Apps Script set ActiveUser and timestamp -


please setting active user in column n. script timestamp column m whenever cell in row updated. however, nothing updates in column n active user.

function onedit() {  var s = spreadsheetapp.getactivesheet();  if( s.getname() == "log" ) { //checks we're on correct   sheet   var r = s.getactivecell();  var user = session.getactiveuser().getemail();   if( r.getcolumn() != 13 ) { //checks column  var row = r.getrow();  var time = new date();  time = utilities.formatdate(time, "gmt-07:00", "yyyy-mm-dd, hh:mm:ss");  spreadsheetapp.getactivesheet().getrange('m' + row.tostring()).setvalue(time);  spreadsheetapp.getactivesheet().getrange("n" + row.tostring()).setvalue(user);      }    };  }; 

am using setvalue(user) incorrectly?

your call setvalue() looks fine. may encountering authorization issue.

can run same code outside of onedit() trigger?

there restrictions on actions can performed inside of onedit trigger. see https://developers.google.com/apps-script/guides/triggers/


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -