AppsScriptPulse

How to Print the Function Call Flow with Stack Trace in JavaScript/Google Apps Script – Digital Inspiration

The printStackTrace method of Java is useful for handling exceptions and errors during development. It tells you the exact line number in your source code and the file name where the problem occurred.

If you are working in the JavaScript / Google Apps Script world, you can use the console.trace() method to output the complete stack inside the web console ( or StackDriver logs for Google Scripts).

A better alternative is that you parse the stack property of the Error object. This contains the entire stack trace along with line numbers, column position and the function names.

Great debugging tip from Amit that you can use in Google Apps Script for parsing the entire stack trace along with line numbers, column position and the function names. Check the source link below for example code and usage.

Source: How to Print the Function Call Flow with Stack Trace in JavaScript – Digital Inspiration

Plotting Points on Image using Google Apps Script · tanaike

This is a sample script for plotting the points on an image using Google Apps Script. Unfortunately, in the current stage, there are no methods for directly editing the image and putting the texts and some shapes in the methods for Google Apps Script. So in this case, it is required to use the workaround.

Clever workaround that uses Google Slides as a canvas for adding text to images.

Source: Plotting Points on Image using Google Apps Script · tanaike

Taking Away the Pain from Unit Testing in Google Apps Script

Unit testing is an extremely important practice. It helps developers avoid bugs easily and lets you know when something is broken immediately. … There are numerous libraries that exist for unit testing in JavaScript, including Jest and Mocha; however, they aren’t necessarily well-adapted to run under the Google Apps Script environment. … For that reason, I built my own library with Google Apps Script in mind.

We’ve featured a couple of community contributions around Google Apps Script Unit Testing and if this is a topic that interests you then the related posts section below will link to additional resources. This post from Dmitry Kostyuk is a great addition and the accompanying UnitTestingApp library that is shared in the post has some very useful Google Apps Script related features such as a dedicated method to check your data is a 2D array (particularly useful in the context of handling spreadsheet values). Follow the source link for more details…

Source: Taking Away the Pain from Unit Testing in Google Apps Script

3 Favourite things in one article – Apps Script, Redis and GraphQL – Desktop Liberation

I’m a great fan of both Redis and GraphQL. You’ll find plenty of articles about them around on this site. Although I’ve showed many examples of GraphQL and Apps Script, it was never possible to connect up Apps Script to Redis, because redis doesn’t use HTTP to communicate between Client and Server. I’ve come across upstash.com (with a free tier), that fronts a redis database with a GraphQL API.

The upstash.com service looks like a nice find from Bruce Mcpherson and his post details how you can use this for cross platform caching.

Source: 3 Favourite things in one article – redis, apps script and graphQl – Desktop Liberation

Redeploying Web Apps without changing the URL in the new Google Apps Script IDE

Redeploying Web Apps without Changing URL of Web Apps for new IDE

A ‘feature’ of the new Google Apps Script editor is managing your script project the deployments. A issue some developers are encountering when updating the published version of their web app is the published url changes. In this gist Kanshi Tanaike describes the problem and highlights how developers can update their published Web App without changing the URL.

Source: Redeploying Web Apps without Changing URL of Web Apps for new IDE

Apps script library with plugins for multiple backend cache platforms – Desktop Liberation

This library used to be part of my cUseful collection, but I’ve decided to pull out into a library in it’s own right. The idea is not only to be able to squeeze more into cache by compression, but also to spread across multiple cache entries. In addition, through the use of plugins, it also allows multiple backend cache stores, all accessed the same way, with the option of creating additional ones. This abstraction allows you to switch platforms as you outgrow them without any main code changes.

Source: Apps script library with plugins for multiple backend cache platforms – Desktop Liberation

How to programmatically schedule weekly time triggers between two dates in Google Apps Script – Yagisanatode

A tool to schedule weekly time triggers between two dates in Google Apps Script. Grab the code and ready the quick-use guide or stick around for a deep dive.

Nice solution from Scott Donald to setup timed triggers for a fixed period so you don’t have to worry about manually adding/removing.

Source: How to programmatically schedule weekly time triggers between two dates in Google Apps Script – Yagisanatode

Create membership expiration in Google Groups for Google Workspace

Manage Google Groups membership expiration with Google Apps Script and Cloud Identity API

As noted by Stéphane Giron Google Group member expiration is not available on all types of Google Workspace accounts, but this post is a useful reminder of what is now possible when it is. The most includes a full explanation and code to get started.

Source: Create membership expiration in Google Groups for Google Workspace

Using Design Patterns in Google Apps Script – Introduction to façade and proxy patterns

A lot of users try and quickly learn GAS and use it to make their lives easier. It’s all great, however the code we sometimes tend to come across on StackOverflow and other sites lacks best practices, hence I thought it was time to start bringing them up and I will start today with design patterns.

As noted by the post author Dmitry Kostyuk the Google Apps Script V8 runtime opens up many new coding opportunities previously not available to Apps Script developers. Using the common use case, fetching data and writing it to a Google Sheet, Dmitry explains how the façade and proxy code patterns can be used to write efficient easy-to-read code.

Source: Using Design Patterns in Google Apps Script

Control Your Nest Thermostat And Build A Temperature Logger In Google Sheets Using Apps Script

Image: Ben Collins

Image: Ben Collins

If you have a Nest thermostat at home, you can access it from your Google Sheet by using Apps Script to connect to the Smart Device Management API. It means you can do some cool stuff like build a virtual, working Nest thermostat in your Google Sheet

Source: Control Your Nest Thermostat And Build A Temperature Logger In Google Sheets Using Apps Script