Google工作表,运行作为所有者的功能 [英] Google sheets, running a function as owner

查看:171
本文介绍了Google工作表,运行作为所有者的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我对于SO非常新颖,并且对JS和Sheets也很新颖。我正在写一张工作表,每个班次有3个班次,首页和4页。除了轮班时间,上午,下午和新台币,每个班次的每个相应的表格都是相同的。

必须处理一些胖手指的人,我认为最好保护床单和打开范围可以填写。启动时只显示首页。我提供了一个开始和结束转换选项的菜单。运行开始班次,并显示相应的班次页面,然后运行结束班次,他们被隐藏。

问题是,我不运行此显示/隐藏,并且作为床单被保护既不能用户。是否有可能让JS的一部分以拥有者权限运行,而不管谁通过菜单调用它?

从可安装的触发器可能是可能的,但是我还没有从菜单项中找到如何操作。

解决方案

我尝试创建一个改变单元格值的菜单项。不幸的是,它不会触发onEdit事件处理程序。所以,我怕你可以从菜单项中做到这一点。解决方法是将验证规则添加到单元格以创建下拉菜单。






对于那些对步骤感兴趣的人:

首先,工作流程:


  • 电子表格有一个名为 Shift

  • 用户可以将值更改为开始,结束或

  • 设置相应的保护当Shift的值改变时
>

下面是步骤:


  1. 创建一个函数,比如 unprotect(),它检查Shift是否为活动单元格,并设置适当的保护在您的项目脚本编辑器中,转至 Resources
  2. / em>
  3. 创建以下规则:从电子表格运行取消保护 on edit

  4. 由于 unprotect()已安装的触发器,它将以拥有者权限运行。


Ok I'm very new at SO and and reasonably new with JS and Sheets. I am writing a sheet for work that runs over 3 shifts with a front page and 4 sheets for each shift. Each corresponding sheet for every shift is identical except for the shift time, AM, PM, and NT.
Having to deal with some fat fingered people I thought it would be best to protect the sheets and open ranges that can be filled in. On start up only the front page shows. I supply a menu with Start and End shift options. Run Start shift and the appropriate shift pages are shown, and then run End Shift and they are hidden.
The issue is that I don't run this show/hide and as the sheets are protected neither can the user. Is it possible to have a section of JS run with owner privilege regardless of who invokes it via the menu?
It may be possible from an installable trigger but I have not yet hunted down how from a menu item.

解决方案

I tried creating a menu item which changes a cell value. Unfortunately it won't trigger the onEdit event handler. So, I'm afraid you can do it from a menu item. A workaround would be adding validation rule to a cell to create a drop-down menu.


To those interested in the steps:

First, the workflow:

  • The spreadsheet has a cell called "Shift"
  • The user can change the value to "Start", "End", or ""
  • Set the appropriate protection when the value of "Shift" changes

Here are the steps:

  1. Create a function, say unprotect(), which checks if "Shift" is the active cell and sets the appropriate protection
  2. In your project script editor, go to Resources > Current project's triggers
  3. Create the following rule: run unprotect from spreadsheet on edit
  4. Since unprotect() is an installed trigger, it will run with the owner permission.

这篇关于Google工作表,运行作为所有者的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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