Updating Google Apps Scripts

As you can probably tell from my previous posts, I’m quite fond of using Google Apps Script as a tool for communicating with various web services, such as Trello or Jira.

I’m sure that there are better ways of achieving the same result, but I’ve stuck with this method because:

  • It’s easy to develop – all you need is a browser, and the debugging is easy
  • Google provide all the infrastructure, so the only barrier to entry for anyone to use the scripts is a Google account.
  • By simply copying a spreadsheet, and following a few simple instructions, users can have powerful scripts up and running in seconds, without relying on any 3rd parties (apart from maybe Google).

Now there is a downside to this approach – updating scripts is a pain. Once someone creates a copy of my spreadsheets/scripts, they’ve essentially forked my code, and therefore won’t automatically receive any future updates. This isn’t ideal, but I do feel more comfortable knowing that users have their own scripts dealing with their data, rather than using a service that I control.

So how do you go about updating a Google Apps Script that you’ve copied? Well it depends on the situation, but basically you have 2 options: kill your copy and start again with the new version, or update your existing script.

Starting Over

The simplest solution is usually to create a copy of the updated script/spreadsheet, follow any setup instructions, and then decommission your previous copy by following these steps:

  1. Remove any web hooks that have been registered. Currently this only applies to the “Pimp Your Trello Card” script, and there is a menu option in the spreadsheet to do this.
  2. Remove any time based triggers configured for the script by selecting “Resources-> Current Project’s Triggers” from the scripts menu and then deleting any triggers (You can get to the script from a spreadsheet by selecting “Tools -> Script Editor..” from the Menu)
  3. Delete the spreadsheet or script.

Update Existing Script

Sometimes it is more efficient to just update your version of the script (such as when the change is small, and the setup process is quite involved), and you can do that by following these steps:

  1. If the script is attached to a spreadsheet that has a “Control” sheet, then update that sheet (if necessary), taking note of any values you’ve entered previously.
  2. Open the new version of the script (If it’s attached to a spreadsheet, you’ll need to create a copy of the new spreadsheet and open it by selecting “Tools -> Script Editor..” from the Menu).
  3. Open your existing version of the script (Again, using “Tools -> Script Editor”).
  4. Copy the text from the new script and paste it into your version. Note: There could be various script files within a script “project”, so you need to copy and paste the code from each corresponding file, and, if necessary create a new script file if it didn’t previously exist.
  5. If the script has been deployed as a web-app, then you’ll need to:
    • Create a new version of the script by selecting “File->Manage Versions” and then clicking “Save new Version”.
    • Redeploy the Web-App by selecting “Publish -> Deploy as Web App”, and then simply updating the version number and clicking on Deploy.

 

/
If you found this post informative, enlightening, entertaining, or it's just helped you solve a problem then please feel free to shout me a coffee for my trouble from extensive menu below:
Today's Menu