函数 onOpen() 没有运行 [英] function onOpen() is not running

查看:11
本文介绍了函数 onOpen() 没有运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的功能包括向文档添加菜单和吐司.我已经验证触发器 (onOpen) 也已设置.它仅在用户进入工具"、脚本管理器"、运行"时才有效.我们有太多背景太多的用户,不知道该怎么做.为什么它不起作用?(使用 Chrome)

My function includes adding a menu and toast to the document. I have verified that the trigger (onOpen) is set as well. It only works when a user goes into Tools, Script Manager, Run. We have too many users with too many backgrounds to expect then to know how to do this. Why isn't it working? (Using Chrome)

function onOpen()
{
  var menus = [{name: "Advance in Workflow", functionName:"sendEmail"}];

     SpreadsheetApp.getActiveSpreadsheet().addMenu("Auto Advance FG Workflow", menus);

  //sheet.toast(Notify/Remind users);
   sheet.toast("While you are here we kindly ask that you do not add, modify or remove     any columns.","Welcome - " + username,8);
 }

谢谢,

推荐答案

我遇到了同样的问题.

我意识到,有时 Google 会创建某种脚本缓存(我习惯于拥有一个测试"脚本,我通常会更改它的内容,有时,脚本会像我没有一样运行一样).

I realized, sometimes Google create some kind of cache of the scripts (I'm used to have a "test" script and I usually alter it's content, and, sometimes, the script runs as if I didn't).

因此,解决 onOpen() 不起作用的方法是更改​​函数名称并手动添加触发器.

So, what I did that solved the onOpen() not working was changing the function name and ading a trigger manually.

当前脚本的触发器……"">

转到资源 -> 当前脚本的触发器..."

Go to "Resources -> Current script's triggers…"

选择要在打开时运行的函数

Choose the function to run on open

它在这里就像一个魅力!

It worked like a charm here!

更新位置信息:或者

然后

这篇关于函数 onOpen() 没有运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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