Google Sheet Add On上的时间触发 [英] Time Trigger on Google Sheet Add On

查看:49
本文介绍了Google Sheet Add On上的时间触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个Google Apps脚本,现在想将其发布为Google表格的附加内容.

I have created a Google Apps Script and now want to publish it as a Google Sheet add on.

脚本的工作方式是每天(通过时间触发器)从API获取一些详细信息,如果在通过API获取的数据中发现任何新信息,则将通知发送给安装程序.

The way script should work is to fetch some details from an API on daily basis (via the time trigger) and send notification to the installer if any new information is found in the data fetched via the API.

人们安装此加载项时,我希望它每天自动为他们运行,并在发现上述更改时向他们发送电子邮件.

When people install this add-on, I want it to run automatically for them everyday, and send them email when changes are found as above.

是否可以在Google Sheet上添加内容?

Is this doable with google sheet add on?

推荐答案

是可行的,唯一的事情是用户需要单击一次Addon菜单(仅限第一次)才能授予必要的权限.单击此按钮,您可以每天启动Trigger.

Yes it is feasible, only thing is users need to Click on to the Addon menu once (For the first time only) in order to Grant the necessary permissions. On this click you can start Trigger for everyday.

这是样本

function onInstall() {
  onOpen(); 
}
function onOpen() {
  var ui = SpreadsheetApp.getUi();
  // Or DocumentApp or FormApp.
  ui.createMenu('Schedule')
  .addItem('Start Schedule', 'menuItem3')
  .addToUi();
}

function menuItem3() {
  createTrigger();
}

function createTrigger()
{
    ScriptApp.newTrigger('startProcess')
    .timeBased()
    .everyDays(1)
    .create(); 
}


function startProcess(){
// Add your processing logic here. e.g. send notifications.
}

这篇关于Google Sheet Add On上的时间触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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