问题
I have created a Google Apps Script and now want to publish it as a Google Sheet add on.
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.
Is this doable with google sheet add on?
回答1:
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.
Here's the sample,
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.
}
来源:https://stackoverflow.com/questions/50382884/time-trigger-on-google-sheet-add-on