Obtaining a timebased trigger using ScriptApp.getUserTriggers() in V8 Runtime

70 views
Skip to first unread message

Robert Gagliano

unread,
Mar 3, 2020, 12:49:23 AM3/3/20
to google-apps-sc...@googlegroups.com
Has anyone else experienced unusual behavior when trying to obtain a timebased trigger from the ScriptApp class in the V8 Runtime?

When performing the following steps in Rhino and V8, I receive two different outcomes (i.e the timebased trigger is not returned in V8 Runtime). Any ideas?

1. Create a new Google Form
2. Open the Apps Script Editor and paste in the below code
3. Disable the Chrome V8 Runtime
4. Execute the createTriggers function
5. Execute the getTriggers function
6. Observe the logs where 2 triggers are returned from the getUserTriggers method
7. Enable the Chrome V8 Runtime
8. Execute the getTriggers function again
9. Observe the logs where only 1 trigger is returned from the getUserTriggers method (where is the timebased trigger?)

function createTriggers(){

  var form = FormApp.getActiveForm();
  ScriptApp.newTrigger('timeBased').timeBased().everyHours(1).create();
  ScriptApp.newTrigger('formSubmit').forForm(form).onFormSubmit().create();
 
}

function getTriggers() {
 
  var form = FormApp.getActiveForm();
 
  var triggers = ScriptApp.getUserTriggers(form);
  Logger.log('user_triggers:');
  Logger.log(triggers);
 
  for (var i = 0; i < triggers.length; i++){
    Logger.log('user_trigger ' + (i+1));
    Logger.log(triggers[i].getHandlerFunction());
  }
   
}

function formSubmit(){
  Logger.log('entering formSubmit function');
}

function timeBased(){
  Logger.log('entering timeBased function');
}

Andrew Roberts

unread,
Mar 3, 2020, 2:25:36 AM3/3/20
to google-apps-sc...@googlegroups.com
There are various issues with V8 triggers, take a look through the tracker.

On Tue, 3 Mar 2020 at 05:49, Robert Gagliano <robga...@gmail.com> wrote:
Has anyone else experienced unusual behavior when trying to obtain a timebased trigger from the ScriptApp class in the V8 Runtime?

When performing the follow steps in Rhino and V8, I receive two different outcomes (i.e the timebased trigger is not returned in V8 Runtime). 

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/1bd423c5-0199-4c74-96a8-047baefbbb83%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages