Reputation: 9168
In an appscript bound to FormApp
, I'm trying to add a onFormSubmit
trigger on the spreadsheet configured as destination of the form, but I neither see spreadsheet as event source from the 'Resources' menu (in script editor) nor can get .newTrigger
working programmatically.
When Script.newTrigger('myFunc').forSpreadsheet(sheetId).onSubmit()
is added in function bound to a menu item (when menu item is clicked), this .newTrigger
call seems to be successful, but without any effect.
I can't see the new trigger anywhere in the script editor (through 'Resources' menu), and when the form is submitted, myFunc
is not fired. Checking ScriptApp.getProjectTriggers().length
, it's still 0.
Is any way to do that? Is it a known limitation (not mentioned clearly in the doc btw)?
Upvotes: 0
Views: 1376
Reputation: 46812
When you run a function like this one :
function test(){
ScriptApp.newTrigger('testFunction')
.forSpreadsheet('1xDOaoSl_______0sFz96PIO6iVF4')
.onFormSubmit()
.create();
}
in a Form, the trigger will be in the Form script editor resource and it will call a function that belongs to the Form script project, not to the SS script editor.
That function will be triggered when the designated spreadsheet receives a form ( this form or another btw...if the spreadsheet receives data from more than one Form).
Hoping it's more clear now.
Upvotes: 1