Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.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
Triggers GoogleApps脚本如何从一个脚本到另一个脚本设置一个函数的触发器_Triggers_Google Apps Script - Fatal编程技术网

Triggers GoogleApps脚本如何从一个脚本到另一个脚本设置一个函数的触发器

Triggers GoogleApps脚本如何从一个脚本到另一个脚本设置一个函数的触发器,triggers,google-apps-script,Triggers,Google Apps Script,我有一个GA脚本,比如说,s1 s1有三个功能,f1、f2和f3 我想从另一个脚本s2为f1(在s1中)设置触发器 有可能吗? 如果是,怎么做?如何从s2中引用f1 “”上的应用程序文档说明,您需要指定函数名来设置触发器,如下所示 // One-time execution only // Use JavaScript Date of 5/17/2012 var date = new Date(2012, 5, 17); var oneTimeOnly = ScriptApp.n

我有一个GA脚本,比如说,
s1

s1
有三个功能,
f1
f2
f3

我想从另一个脚本
s2
f1
(在
s1
中)设置触发器

有可能吗? 如果是,怎么做?如何从
s2
中引用
f1

“”上的应用程序文档说明,您需要指定函数名来设置触发器,如下所示

  // One-time execution only
  // Use JavaScript Date of 5/17/2012
  var date = new Date(2012, 5, 17);
  var oneTimeOnly = ScriptApp.newTrigger("runCommand")
      .timeBased()
      .at(date)
      .create();
看起来,函数“runCommand”必须在同一个文件中

我还阅读了关于图书馆的文档。我已将脚本
s1
包含在
s2
中。我还可以从
s2
调用
s1.f1
s1.f2
中的方法。但我不能扣动扳机

当我执行:

var date = new Date(2014, 2, 17);  
var oneTimeOnly = ScriptApp.newTrigger("s1.f1")
      .timeBased()
      .at(date)
      .create();

我收到错误:
无法找到所选函数。

只能为项目中的本地函数创建触发器。为了完成您想要的,您需要为项目中的库函数创建一个包装函数