简体   繁体   English

Google Spreadsheets-为什么我的脚本对我来说是文档所有者,但对共享编辑器不起作用?

[英]Google Spreadsheets - why do my scripts work for me the doc owner but not shared editors?

I have a script that adds a 'last modified' date onto a cell in each spreadsheet so I can see when individual spreadsheet of different programs have been updated. 我有一个脚本,可以在每个电子表格的单元格上添加一个“上次修改日期”,以便可以看到何时更新了不同程序的各个电子表格。 It only updates when I update the file not when another person I shared the file with does. 它仅在我更新文件时更新,而不在与我共享文件的另一个人更新时更新。 I do have the cell locked so no one can delete it by mistake. 我确实锁定了该单元,所以没有人可以错误地删除它。 here is the script i have: 这是我有的脚本:

function onEdit(e) {
var d = new Date()
e.source.getActiveSheet()
.getRange('S1')
.setValue('Last Modified:\n' +d
.toLocaleDateString() )
}

I saw an older post on this similar topic that says: 我在类似主题上看到了一篇较旧的文章,内容为:

You currently have two triggers: a simple trigger and an installable trigger. 当前,您有两个触发器:一个简单触发器和一个可安装触发器。 Naming a function 'onEdit' (like you did) is already using a simple trigger. 命名函数“ onEdit”(就像您所做的一样)已经在使用简单的触发器。 A simple trigger can run without the authorization of the user, an installed trigger always need to be authorized by the user. 一个简单的触发器可以在没有用户授权的情况下运行,安装的触发器始终需要用户授权。 So try removing the installed trigger and see if it then works ? 因此,请尝试删除已安装的触发器,看看它是否可以工作?

But I am not sure what the installed trigger is or if I have one? 但是我不确定安装的触发器是什么,或者我是否有触发器? When I look for triggers it says i don't have any. 当我寻找触发器时,它说我没有任何触发器。 If you have any ideas please let me know. 如果您有任何想法,请告诉我。 I am volunteering setting up these spreadsheets for a non profit organization and am new to scripting. 我自愿为非营利组织设置这些电子表格,并且是脚本编写的新手。

Thank you, Amy 谢谢艾米

Your trigger and script are fine. 您的触发器和脚本很好。 The issue has everything to do with 这个问题与一切有关

I do have the cell locked so no one can delete it by mistake. 我确实锁定了该单元,所以没有人可以错误地删除它。

You either have to remove the restricted protection from the cell or alter the protection to the warning variety Show a warning when editing this range . 您要么必须从单元格中删除受限制的保护,要么将保护更改Show a warning when editing this range Then you should be good to go. 那你应该很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM