Google Apps Script is a powerful tool for automation. It has a few downsides like not being able to save certain queries that you might call for multiple scripts It also doesn’t make it easy to take changes to XML formats into account when updating old script. Google has a few ideas to make these processes a little easier.
Gustavo Moura of the Google Docs team announced the availability of libraries and versions in Apps Script today. These two additions drastically change what can be done with Apps Script. The library functionality will be especially useful for those who write a lot of code using App Script.
The first step is of course writing the library itself. It’s pretty straightforward, but Moura provides an example of a library he wrote to call the WeatherService. The best part about the library creation tool in Apps Script is that it creates documentation based on the code comments. You can also hide certain bits of code from the user by ending its name with an underscore.
After you put all that hard work into writing the library, you will obviously want to save it. In Apps Script, the saving is now done through versions. It’s just like any version of software where the last stable version is available for all to use while you work on updates to the actual script. When you update the script to a stable state, publish a new version.
There will be many libraries over the next few weeks, months and years as more people begin building in Apps Script. You might even want to make use of the libraries that these users create. To share a library with another user, all you need to provide is your permission and a project key.
Once you get knee deep into library creation and using other libraries, there are three features that developers will want to take advantage of:
Documentation – In the Script Libraries dialog, you can click on the title link to navigate to documentation page for the library.
Development Mode can be used to test changes to a library without saving a new version.
Autocomplete in Script Editor – Typing in the editor will auto-complete your library function names.
Google already has a decently sized list of script libraries for users to play around with. The libraries range from the aforementioned WeatherService to a YouTube library that can read different kinds of video feeds. Check them out here to see if any of them tickle your fancy.