Google Apps脚本-时间驱动的触发器不执行任何SpreadsheetApp.getUi函数 [英] Google Apps script - Time-driven trigger not executing any SpreadsheetApp.getUi functions

查看:47
本文介绍了Google Apps脚本-时间驱动的触发器不执行任何SpreadsheetApp.getUi函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么时间驱动触发器不调用任何‍‍ SpreadsheetApp.getUi Browser.xxx()函数?

Why would Time-Driven triggers not call any ‍‍‍‍SpreadsheetApp.getUi or Browser.xxx(), functions?

如果我手动播放该函数,则执行这些行,但是使用基于时间的触发器,该函数将被调用,除上述任何调用之外,所有其他行均将被执行.

If I manually play the function, the lines are executed, but with a time based trigger, the function is called, all other lines are executed, except any calls to the above.

我想要一个时间驱动的触发器,以根据时间频率设置在电子表格上显示警报.

I wanted a time-driven trigger to display an alert on a spreadsheet based on the time freq set.

这是一个简单的代码,以时间驱动的触发器设置为每分钟运行为例.尝试了其他各种时间设置.

Here is a simple code, Time-driven trigger set to run every minute as an example. Tried it with various other time settings.

function InputTime()
{

Logger.log("This code ran");     // This works fine.

SpreadsheetApp.getUi().alert("Warning 1");        // Does not work

this.SpreadsheetApp.getUi().alert("warning 2");   // Does not work

Browser.msgBox("warning 3");                     // Does not work
}

有什么主意吗?另外,通过首先获取工作表的ID和工作表名称(如Sergi在此处建议的那样)来修改工作表中的值,可以对工作表进行良好的编辑.同样,有什么方法可以将警报通知绑定到特定电子表格?

Any idea? Also, modifying the values in the sheet by first getting the Id of the sheet and the sheet name ( as suggested by Sergi here), allows the sheet to be editied fine. Similarly is there any way to tie Alert notifications to the particular spreadsheet?

推荐答案

时间触发的触发器函数无法与Ui进行交互,它们在自己的作用域中运行,独立于您的会话.

Time-Driven triggers functions are unable to interact with Ui, they run in their own scope , independently of your session.

这是预期的行为,您无能为力.

This is the intended behavior, nothing you can do about it.

这篇关于Google Apps脚本-时间驱动的触发器不执行任何SpreadsheetApp.getUi函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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