“服务错误:电子表格";错误-保护类的Google脚本问题 [英] "Service Error: Spreadsheets" Error - Google Script Issue with Protection Class

查看:61
本文介绍了“服务错误:电子表格";错误-保护类的Google脚本问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个项目中有一个子函数,当工作表被复制时,我可以使用该子函数来复制保护.这已经工作了好几个月没有问题了.运行它时突然出现错误服务错误:电子表格".我知道它在星期天工作没问题,并且代码没有任何更改.通过一系列Logger语句,我知道错误发生在行

I've got a sub function in a project that I use to copy protections as a sheet is duplicated. This has worked for months without issue. I'm suddenly getting an error "Service Error: Spreadsheets" when I run it. I know it worked without issue on Sunday and there has been no changes to the code. With a series of Logger statements I know the error occurs on the line

var p = sheet.getProtections(SpreadsheetApp.ProtectionType.SHEET)[0];

我已经做了一些测试,看来大多数保护类命令都在触发错误.我已经完成了一次Google搜索,只能找到15小时前与某人遇到类似但略有问题的其他相关帖子.在我看来,这是Google方面的问题.任何人都可以确认或提供任何有关如何进行的见解吗?他们是否有可能在做某事,并且会尽快修复?

I've done some testing and it appears that most of the protection class commands are triggering the error. I've done a google search and can only find one other relevant post from 15 hours ago with someone running into a similar but slightly problem. It appears to me this is an issue on the google side of things. Can anyone confirm or give any insight as to how to proceed? Are they likely working on something and it'll be fixed soon?

function DuplicateProtections(Week) { 
    //Duplicates the selected Template keeping all the protections
   var sheet = ss.getSheetByName(Week);
   var sheet2 = sheet.copyTo(ss).setName('Temp');
   var p = sheet.getProtections(SpreadsheetApp.ProtectionType.SHEET)[0];
   var p2 = sheet2.protect();
   p2.setDescription(p.getDescription());
   p2.setWarningOnly(p.isWarningOnly());  
   if (!p.isWarningOnly()) {
      p2.removeEditors(p2.getEditors());
      p2.addEditors(p.getEditors());
   }
   var ranges = p.getUnprotectedRanges();
   var newRanges = [];
   for (var i = 0; i < ranges.length; i++) {
      newRanges.push(sheet2.getRange(ranges[i].getA1Notation()));
   } 
   p2.setUnprotectedRanges(newRanges);
}

推荐答案

这似乎是一个错误!

在Internet上搜索有关您的问题的信息时,我在 Google问题跟踪器上遇到了以下问题:

This seems to be a bug!

Searching on the Internet about your issue I came across the following issue on Google Issue Tracker:

应用脚本集并获取保护服务错误

似乎很多人都遇到了与您相同的问题,并且所有问题都始于昨天(2020年2月5日).您可以点击此页面左上方的问题编号旁边的☆,因为它可以让Google知道更多人遇到此问题,因此更有可能看到更快的结果.

It seems a lot of people are having the same problem as you and it all started yesterday (5th February 2020). You can hit the ☆ next to the issue number in the top left on this page as it lets Google know more people are encountering this and so it is more likely to be seen to faster.

我希望这对您有用.

这篇关于“服务错误:电子表格";错误-保护类的Google脚本问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆