Christoph Pelzer
Christoph Pelzer

Reputation: 88

Google App-Script save global Spreadsheet scirpt

So I was using spreadsheets for a Game to ease things up for me and be organized about it. I am using sheets that contain information on columns A:D and a random amount of rows.

Column D is a data validation checkbox.

After some time I started removing checked lines manually because I didn't need them anymore and I thought maybe I'd see if I can automate the deletion in google and found out about AppScripts. My script works as Follows ->

I've written an Event based trigger that reacts to sheet manipulation. I then check if the checkbox was ticked and if so remove the row.

Here's my problem:

After I removed all rows of the sheet I wanted to delete the entire document. Next time I'm playing I'd import a new csv file with completely different data into the sheet and want to use the same AppScript again on that new document. The thing is I seem to be unable to create a script that is available to all SpreadSheet documents. The AppScript seems to be only existent in that one document. I found out that I can have independent AppScript projects but if I try to add a trigger to those I can only use timed triggers and not event based ones.

The questions would be:

  1. Can I somehow save an AppScript project that is independet from a specific Google Sheets Document so I can use that (and an Event based trigger) in any new document that I might create?

Thank you for reading ;)

Upvotes: 0

Views: 50

Answers (1)

Wicket
Wicket

Reputation: 38131

You can create a standalone script and create from it installable triggers for all the spreadsheets that need them. Please bear in mind that simple triggers will not work from the standalone script unless you use the Run > Test as add-on feature.

NOTE: The triggers page for your script on https://script.google.com will list all the triggers but it will not show what trigger act on which spreadsheet so you might found useful to log the spreadsheet name / url to make it easier to troubleshoot your triggers.

Resources

Upvotes: 0

Related Questions