Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 使用应用程序脚本google sheets获取活动电子邮件id和行号_Google Apps Script_Google Sheets - Fatal编程技术网

Google apps script 使用应用程序脚本google sheets获取活动电子邮件id和行号

Google apps script 使用应用程序脚本google sheets获取活动电子邮件id和行号,google-apps-script,google-sheets,Google Apps Script,Google Sheets,活动用户电子邮件id,包括行号和当前日期、月、年、小时、分钟、秒(例如:“mrx@gmail.com+行编号+06/08/2020-10:08:25“不带任何空格,+,-,:,符号。格式应如下”mrx@gmail.com106082020100825")如果同一行在列E中有任何数据,则必须出现在列A中;如果删除列E中的同一行,则必须消失。第一次提问: function onMyEdit(e){ //e.source.toast('Entry'); console.log(JSON.str

活动用户电子邮件id,包括行号和当前日期、月、年、小时、分钟、秒(例如:“mrx@gmail.com+行编号+06/08/2020-10:08:25“不带任何空格,+,-,:,符号。格式应如下”mrx@gmail.com106082020100825")如果同一行在列E中有任何数据,则必须出现在列A中;如果删除列E中的同一行,则必须消失。

第一次提问:

function onMyEdit(e){
  //e.source.toast('Entry');
  console.log(JSON.stringify(e));
  const sh=e.range.getSheet();
  if(sh.getName()=='Sheet1' && e.range.columnStart==5 && e.range.rowStart>1) {
    if(e.range.getValue()!='') {
      //e.source.toast('conditional');
      e.range.offset(0,-4).setValue(e.user + '\n' + e.range.rowStart);
    }else{
      e.range.offset(0,-4).setValue('');
    }
  } 
} 
 
编辑后:

function onMyEdit(e){
  //e.source.toast('Entry');
  console.log(JSON.stringify(e));
  const sh=e.range.getSheet();
  if(sh.getName()=='Sheet1' && e.range.columnStart==5 && e.range.rowStart>1) {
    if(e.range.getValue()!='') {
      //e.source.toast('conditional');
      e.range.offset(0,-4).setValue(e.user + e.range.rowStart + Utilities.formatDate(new Date(),Session.getScriptTimeZone(),"dd/MM/yyyyHH:mm:ss"));
    }else{
      e.range.offset(0,-4).setValue('');
    }
  } 
} 
 

当我运行它时,它显示“TypeError:无法读取未定义的属性'range'(第4行,文件“Code”)”您是如何运行它的?我单击了脚本编辑器中的三角形按钮,还测试了在列e中键入一些文本,但没有结果。您无法运行需要脚本编辑器中的OneEdit触发器事件对象的函数。除非您提供事件对象,否则我总是使用可安装的触发器构建这些函数,并使用console.log和e.source.toast()从页面中测试它们