Appscript 部署未运行宏

问题描述 投票:0回答:1

朋友给了我一个带有应用程序脚本宏的电子表格,我们想使用它。

电子表格的目的是显示不同时区(PST/MST/CST/EST)特定时间段(即 2 周内或 8 小时内)内跟进的日期时间。应用脚本中的所有宏文件看起来都不错,清单文件也看起来正确,但当我部署时,它不会更新工作表中的任何单元格。如果我运行各个宏,它们会更新工作表中的单元格。它应该不断地将日期时间更新为当前时间或至少在打开的工作表上。

我是谷歌应用程序脚本的新手,但有良好的编码背景,我觉得这应该很简单。我可能缺少运行文件或运行调用,但我不确定应该在哪里添加。如果需要,可以添加任何其他相关信息。

JSON 清单文件示例:

{
  "timeZone": "America/Toronto",
  "exceptionLogging": "STACKDRIVER",
  "runtimeVersion": "V8",
  "dependencies": {
    "libraries": [
      {
        "userSymbol": "FollowupTagfilterforBCTeam",
        "libraryId": "186UPce75w8KpinMaHxLVgk494S7nthWonp-Iruh_Yo0PsnXqWb2qtBrl",
        "version": "0",
        "developmentMode": true
      }
    ]
  },
  "webapp": {
    "executeAs": "USER_DEPLOYING",
    "access": "ANYONE_ANONYMOUS"
  },
  "sheets": {
    "macros": [
      {
        "menuName": "updateCSTTime10days",
        "functionName": "updateCSTTime10days"
      },```

上述宏文件示例:

function updateCSTTime10days() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("CST");
  var cstTime = new Date(new Date().getTime() + (240 * 60 * 60 * 1000)); // Adding 240 hours     for CST
  var formattedDate = cstTime.toLocaleString("en-US", {timeZone: "America/Chicago", year:     'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-    digit'});
  sheet.getRange("B6").setValue(formattedDate);
}

尝试单独运行并且宏起作用。 尝试做触发器,但有数百个,并且开始在打开时失败(也认为有一种更聪明的方法来调用它们而不是每个触发器) 测试了不同的部署并确保库排列整齐

google-sheets google-apps-script web-applications
1个回答
0
投票

通过创建一些新脚本进行修复,需要一些学习,但一个添加了一个将执行所有宏的按钮,另一个是一个基于 onOpen 时间的触发器,它将每分钟运行所有宏,直到工作表关闭。

© www.soinside.com 2019 - 2024. All rights reserved.