简体   繁体   中英

Time Trigger on Google Sheet Add On

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?

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.
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM