Google表自定义功能在一张纸上起作用,在另一个表上失败 - 相同的权限

发布于 2025-02-12 05:42:26 字数 1250 浏览 2 评论 0原文

我有两个图纸,类似的列,其中自定义函数从行中的后续单元格返回一个值。这两个床单都在同一文件夹中,我对这两个床单都有相同的编辑权限。

在一张纸上,该功能可以完美。在另一个表上,功能通过

“您无权访问请求的文档。”

在大多数情况下,此错误表明您要访问另一个文档/表,或者运行脚本的人员无法访问当前(活动)表。我相信,如果尝试使用.setValue(),也会发生这种情况。

但是,这是一个自定义功能,我既不访问任何其他表/文档。我的访问使我能够编辑表,尽管自定义功能不作为给定用户运行并有一些限制。

我做了一些研究,发现我无法运行任何这些命令。这并不详尽,只是我无法运行的一些数据收集功能。

sheet.getLastColumn();
cell.getValue();
sheet.getRange(rangeParameters).getValues();

但是,我可以使用:

sheet.getRange(rangeParameters);
cell.getRow();
cell.getColumn();

因此,在有效的情况下,我可以创建一个范围对象,一个单元对象,一个表对象,但是我不能返回任何值。奇怪的是,我无法获得表格的最后一列(或最后一行),但可以获取单元格的行或列。

同样 - 确切的代码在一个纸上完美运行,另一个纸会失败。

由于组织,我工作,所以我无法共享更多信息。可以说,所有脚本和床单都可以通过批准过程运行脚本。我在提供该访问权限的团队中工作。两个电子表格都具有相同的访问权限。

我没有在工作区管理控制台中找到任何限制脚本访问的东西。但是,这是我写的一些代码,这些代码在一张纸上工作,另一个代码失败。

function returnStatus(input) {
  const ws = SpreadsheetApp.getActiveSpreadsheet();
  const sheet = ws.getActiveSheet();
  const cell = sheet.getActiveCell();
  const row = cell.getRow();
  const column = cell.getColumn();
  const cellVal = cell.getValue();  //FAILS HERE
  return row;
}

我注意到它在哪里失败。

我很好奇,如果有人知道为什么自定义功能这个简单的函数会因该错误而失败。我缺少的工作空间设置吗?

I have two sheets, similar columns, where a custom function returns a value from subsequent cells in the row. Both sheets are in the same folder and I have the same edit permission on both.

On one sheet, the function works perfect. On another sheet, the function fails with a

"You do not have permission to access the requested document."

In most cases this error either indicates you are accessing another doc/sheet or the person running the script does not have access to the current (active) sheet. I believe it can also happen if attempting to use .setValue().

However, this is a custom function and I am neither accessing any other sheet/document. My access allows me to edit the sheet, though custom functions do not run as a given user and have some restrictions.

I did some research and found I could not run any of these commands. This is NOT exhaustive, just some of the data gathering functions I cannot run.

sheet.getLastColumn();
cell.getValue();
sheet.getRange(rangeParameters).getValues();

I can, however, use:

sheet.getRange(rangeParameters);
cell.getRow();
cell.getColumn();

So, in effective, I can create a range object, a cell object, a sheet object, but I cannot return any values. Odd also that I cannot get the last column (or last row) of a sheet but can get the row or column of a cell.

Again - the exact code runs perfectly on one sheet, fails on the other.

Due to the organization I work for I cannot share much more information. Suffice to say, all scripts and sheets allowed to run scripts to through an approval process. I work on the team that provides that access. Both spreadsheets have the same access granted.

I have not found anything limiting script access in the Workspace admin console. However, here is some code I wrote that works on one sheet, fails on the other.

function returnStatus(input) {
  const ws = SpreadsheetApp.getActiveSpreadsheet();
  const sheet = ws.getActiveSheet();
  const cell = sheet.getActiveCell();
  const row = cell.getRow();
  const column = cell.getColumn();
  const cellVal = cell.getValue();  //FAILS HERE
  return row;
}

I've noted where it fails.

I'm curious if anyone knows why a custom function this simple would fail with that error. Are there Workspace settings that I'm missing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文