我有一个简单的谷歌应用程序脚本,可以从我正在处理的当前电子表格中执行一些操作,然后将数据传输到另一个电子表格,如下所示。
function unplannedSubmit()
{
//Some pre-requisite codes here//
//Input is transferData, output is sending those data to a certain range in ds_main
var ds = SpreadsheetApp.openByUrl("URL will be inserted here");
var ds_main = ds.getSheetByName("Job Management - All");
ds_main.getRange(1, 1, 5, 10).setValues(transferData);
}
无论出于何种原因,当我尝试手动运行unplannedSubmit()时,它运行得非常好。我做了另一个代码部分来确定是否运行这些函数,并将它们放入onEdit()函数中,该函数应该在对活动电子表格进行编辑时运行
function onEdit()
{
var ss = SpreadsheetApp.getActiveSpreadsheet();
var ss_submitList = ss.getSheetByName("Jobsheet Change List / Request");
var ss_unplanList = ss.getSheetByName("Unplanned Job List / Application");
//Check for unplanned import function
if (ss_unplanList.getRange("A1").getValue() > 0) unplannedSubmit();
}
但这样做只会给我带来这个错误:
Error message on trigger
{
"oauthScopes": [
"https://www.googleapis.com/auth/spreadsheets"
],
"timeZone": "Asia/Kuala_Lumpur",
"dependencies": {},
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8",
"webapp": {
"executeAs": "USER_DEPLOYING",
"access": "ANYONE_ANONYMOUS"
}
}