0

I am currently trying to call a function with an argument in Google app's newTrigger() function.

I have a function called writeToSheet(sheet). Where as I enter the sheet name into the argument and the custom output is written to said sheet. It all works fine, but I would like to pass this into a time driven trigger with different sheets being written to at different times.

So far, entering ScriptApp.newTrigger('writeToSheet("Production Sheet")') within Google's trigger building example doesn't work. How would you go about solving this problem?

Cameron Roberts
  • 7,127
  • 1
  • 20
  • 32
Mike B
  • 101
  • 1
  • 3

2 Answers2

0

So far, I have had to create a function that executes what I need.

function prodSheetUpdate() {
  writeToSheets("Production Sheet");
}

Then pass that function in my trigger.

ScriptApp.newTrigger("ProdSheetUpdate")
 ...
 ...

It doesn't seem like you can pass an argument in a trigger. If anybody knows otherwise, I am still curious!

Mike B
  • 101
  • 1
  • 3
-1

you must pass a string to newTrigger

ScriptApp.newTrigger('writeToSheet('+'Production Sheet'+')')

or

var mystring ScriptApp.newTrigger('writeToSheet('+mystring+')')

Rahul Singh
  • 918
  • 14
  • 31