AppsScriptPulse

Executing Function with Minutes timer in Specific Times using Google Apps Script [and tips on creating triggers in V8]

This is a sample script for executing a function with the minutes timer in the specific times using Google Apps Script. For example, when this sample script is used, the following situation can be achieved: Execute a function every 10 minutes only in 09:00 – 12:00 and 15:00 – 18:00 for the weekday.

A clever bit of coding from Kanshi Tanaike for running a Google Apps Script on a defined schedule. The part I found particularly interesting was the solution for programmatically setting triggers in the V8 runtime:

This sample script used Web Apps. Because when v8 runtime is used, when the trigger is set from the function executing by a trigger, the trigger is disabled. This is the recognized bug. But unfortunately, this has still not been resolved. (September 21, 2021) But, when the trigger is installed by Web Apps, no issue occurs. So, please deploy Web Apps.

For the sample code and explanation visit the source link.

Source: Executing Function with Minutes timer in Specific Times using Google Apps Script

How to call Google Cloud Run (or Cloud Functions) from Google Apps Scripts

I struggled how to make an authenticated call from Apps Scripts to Cloud Run even though I had owner rights on the GCP project. This post describes how to do it without reinventing the wheel.

Some very useful setup tips for using Cloud Run with Google Apps Scripts including additional references if you are keen to explore more.

Source: How to call Google Cloud Run (or Cloud Functions) from Apps Scripts

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

Help! My time triggers are not in sync! : How to update your Google Apps Script project time zone. – Yagisanatode

If you have made it to this post you are probably a little frustrates about why your Google Apps Script time triggers are not running on or around the times that you have designated … To cut to the chase, the likely cause of clock triggers not running in the time range that you have selected is that the time zone in your Google Apps Script project is out.

Scott ‘Yagi’ Donald provides some very useful tips on how you can check and adjust your Apps Script project’s timezone.

Source: Help! My time triggers are not in sync! : How to update your Google Apps Script project time zone. – Yagisanatode

Debugging in Google Apps Script – Jeff Everhart

Most of the comments I get on this site have to do with someone trying something I’ve written about that isn’t working for them. In most cases, error messages can be your friends since they can point to the particular place your script failed and give you additional insight into why it failed.

This post will describe some of the ways you can use the built-in tools of the Google Apps Script environment to debug or troubleshoot your own scripts. My goal here is start from the easiest to implement and work towards more difficult, but more efficient, methods of debugging.

Source: Debugging in Google Apps Script – Jeff Everhart

GGvulnz — How to check your domain and groups settings

This article will highlight how you have to be careful about settings when you make some content available publicly, like Groups or Drive file.

The original article describe how an external person of the domain can subscribe to your Slack company channel by using a Google Groups that is publicly accessible. Stéphane Giron’s article helps answer the question – how to prevent and how to identify if some groups are concerned.

Source: GGvulnz — How to check your domain and groups settings

Google Apps Script Development – Best Practices – Andrew Roberts

This is an overview of the various techniques and best practices I have evolved in developing Google Apps Scripts over the years. Of course Google have got a few suggestions of their own, and there are plenty of more general …

This includes some good design pattern considerations for Apps Script projects as well as links to testing libraries, boilerplate frameworks, and extensions that help manage Apps Script work.

Source: Google Apps Script Development – Best Practices – Andrew Roberts

Gmail scopes automatically invalidated when a user changes the password requiring re-authentication 

I stumbled upon this particular oddity a few weeks ago when a client asked me to resolve an issue.
It turns out that if your application leverages gmail scopes, those scopes are automatically invalidated when a user changes the password on that gmail account. The client in question had changed their password which triggered an authorization prompt. Something to watch out for.
Nice highlight from Dimu Designs, the source thread is open for other ‘gotchas’.

Source: The more you know! – Google Groups