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 识别在运行时调用的触发器UniqueId_Google Apps Script_Triggers - Fatal编程技术网

Google apps script 识别在运行时调用的触发器UniqueId

Google apps script 识别在运行时调用的触发器UniqueId,google-apps-script,triggers,Google Apps Script,Triggers,我创建了一个触发器,其值getUniqueId()等于3303211292973583,它每1小时调用一次mytrigfunction。我保存3303211292973583值和个人电子邮件id(example@it.com)在一张纸上 mytrigfunction() { during this function execution I compare 33032101292973583 from my sheet with current invoked trigger if yes th

我创建了一个触发器,其值getUniqueId()等于3303211292973583,它每1小时调用一次mytrigfunction。我保存3303211292973583值和个人电子邮件id(example@it.com)在一张纸上

mytrigfunction()
{
during this function execution 
I compare 33032101292973583 from my sheet with current invoked trigger
if yes then send the mail to (example@it.com) person
otherwise
send mail to some other person (some@it.com) with some other trigger unique id matched
}
假设您的问题是“我可以将触发器触发时从事件中提取的ID与创建触发器时获得的ID进行比较吗?”答案是肯定的,有点像!我发现在19位数字中,你只能比较前14位,后5位似乎不同,所以你需要把它们去掉

触发器调用的事件处理程序函数将被传递一个事件,它的属性之一是触发器的ID,因此我使用此代码获取ID(与getUniqueId()返回并使用PropertiesService存储的ID匹配的14个字符):


你的问题是,这不起作用吗?但如何提取ID?密码是什么?如何拿到身份证谢谢安德鲁,经过一番挖掘,我终于解决了这个问题。真是个好发现。看来我们不是唯一一个用头撞这个的人!所以这是某种舍入误差。那么你是否发现Eskay的答案适合你。
function triggerEventHander(event) {
  var eventTriggerId = event.triggerUid.toString().slice(0,14)
}