5

If I create a Google apps script, can I hook it up to Google spreadsheet to run based on an event, or must I manually invoke it?

I don't know if Google Sheets supports any events.

For example: a Google app script that strikes out rows in the spreadsheet that have been marked completed by way of a column having the digit 1 beside completed rows. I would like this to run whenever a row is modified, or even when the spreadsheet is first loaded.

Community
  • 1
  • 1
John K
  • 28,441
  • 31
  • 139
  • 229
  • Removed google-app-engine tag, as this question is not actually related to AppEngine in any way. – Adam Crossland Mar 19 '10 at 13:57
  • @Adam C: Thanks, I was unsure when I posted that tag - figured somebody else would know the diff and correct it if need be. – John K Mar 19 '10 at 17:13

1 Answers1

3

The function onOpen() is automatically executed every time a Spreadsheet is loaded. In the future, we will expose a general event API, but until then you can simply define your own function as long as it is called onOpen().
From the Section 2 of the Tutorial

There is also function onEdit() as can be viewed in at:

http://www.google.com/support/forum/p/apps-script/thread?tid=584a17c79e4c04d5&hl=en

It seems that event handling is in flux and dependent on security issues being worked out.

Nakilon
  • 34,866
  • 14
  • 107
  • 142
  • Out of curiosity would you per chance be a Google employee on the Docs team? ref: "we" – John K Mar 21 '10 at 01:34
  • 1
    @jdk I am not a Google employee. The 'we' was part of the tutorial I copied and pasted. Should have been more specific about attribute-From the Section 2 of the Tutorial. –  Mar 27 '10 at 15:34