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

If you have made it to this post you are probably a little frustrated about why your Google Apps Script time triggers are not running on or around the times that you have designated. Of course, you could simply just be a well-oiled machine and want to know how to update the time zone of your project for your client.

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.

How to check your Project’s Timezone

So, how do you check the time zone of your project?

If you need to do it programmatically you can use the Session class and the getScirptTimezone() method. Something like this will log your project’s timezone:


Alternatively, you can check out your project manifest file.

To do this in your Google Apps Script IDE, go to your sidebar and select the Project settings cog and then check the Show “appsscript.json” manifest file in editor checkbox under the general settings.

Google Apps Script manifest file
Click to Expand!

Go back to the editor and your “appscript.json” file will be visible. Select it and you will be able to see the current time zone for your project.

Google Apps Script time zone in manifest file
Click to Expand!

Changing the timezone

So, at the time of writing this, I found the information on the correct syntax for the time zone in the manifest in the docs either too simplified or when clicking the associated link, too convoluted for my poor goat brain to handle.

In short, you can add certain countries followed by their city. Like this:

“Australia/Sydney”

Or in your code, like this:

Alternatively, you can use GMT time in this format:

“Etc/GMT-10” << For Sydney, Australia

The -10 can be changed to whatever GMT you need.

Resources

After a bit of testing and some searching, I came across these two resources to help you when entering in the correct time zone.

Alternatively, I have created a Google Sheet that contains:

  • A full timezone list with aliases
  • A full timezone list without aliases
  • A GMT only list

These might be useful for bookmarking or exporting certain Google Sheet tabs as CSVs.

Just go to File > Make a copy so you have your very own version of the document.

Finally, here is a list of all the GMT values:

Standard Offset GMT
-12:00:00 Etc/GMT+12
-11:00:00 Etc/GMT+11
-10:00:00 Etc/GMT+10
-09:00:00 Etc/GMT+9
-08:00:00 Etc/GMT+8
-07:00:00 Etc/GMT+7
-06:00:00 Etc/GMT+6
-05:00:00 Etc/GMT+5
-04:00:00 Etc/GMT+4
-03:00:00 Etc/GMT+3
-02:00:00 Etc/GMT+2
-01:00:00 Etc/GMT+1
+00:00:00 Etc/GMT-0
+01:00:00 Etc/GMT-1
+02:00:00 Etc/GMT-2
+03:00:00 Etc/GMT-3
+04:00:00 Etc/GMT-4
+05:00:00 Etc/GMT-5
+06:00:00 Etc/GMT-6
+07:00:00 Etc/GMT-7
+08:00:00 Etc/GMT-8
+09:00:00 Etc/GMT-9
+10:00:00 Etc/GMT-10
+11:00:00 Etc/GMT-11
+12:00:00 Etc/GMT-12
+13:00:00 Etc/GMT-13
+14:00:00 Etc/GMT-14

And a link to the GMT converter:

GMT Converter

I hope this saves you a little time.

Create and Publish a Google Workspace Add-on with Apps Script Course

Need help with Google Workspace development?

Go something to solve bigger than Chat GPT?

I can help you with all of your Google Workspace development needs, from custom app development to integrations and security. I have a proven track record of success in helping businesses of all sizes get the most out of Google Workspace.

Schedule a free consultation today to discuss your needs and get started or learn more about our services here.


~Yagi

Google Apps Script: Create a Select All Checkbox to Tick Checkboxes in Any Desired Range in Google Sheets

Google Apps Script: isChecked(), switch, filter, map

One Checkbox to Rule them All

Now that’s a fantasy novel I could be my gums into.

Have you ever created a Google Sheet projects where you could really use a select all checkbox (they call them ‘Tick-boxes’ in Google Sheets)? Sure you can copy a range of tickboxes and paste the same range etc. But can you really trust your users not to mess that up?

People are used to select-all checkboxes in their computerised lives. It’s always better to work with familiarity to provide a better user experience rather than try and teach the user on the fly how to do something your way.

With this in mind, I went about creating a select-all checkbox for Google Sheets. Here is a little demo of how it all works. All the black background Tick boxes are select All boxes. These boxes have been assigned a range of other checkboxes that will be either checked or unchecked depending on the main select-all boxes state.

Google Select All Demo with Google Apps Script
Select All Demo

As you can see, the select all checkbox only changes the tick boxes in the assigned range. It does not affect any other non-tick box data in the same range.

To get this up and running on your own project, all you need to do is copy and paste in the two code files in your Google Apps Script editor. The first code file is the function that runs the check-all code. The other file stores all the select-all checkboxes and the ranges that they will affect.

Let’s take a look at the code and then run through a quick use guide before finishing off with an example.

Those of you who want to dive into the nuts and bolts of the code, there will be more explanation of each element of the code at the end.

The Code

Continue reading “Google Apps Script: Create a Select All Checkbox to Tick Checkboxes in Any Desired Range in Google Sheets”

Google Apps Script – URL Fetch JSON data from an API and add it to a Google Sheet – Ripple API example

Google Apps Script – UrlFetchApp, SpreadsheetApp, Ripple API, Time Triggers

I have been very fortunate of late to have the patronage of the Ripple XRP cryptocurrency community via XRP Tip Bot and Coil. This is no small part due to the support of user Recreational Rex from Twitter.

Full disclosure here, I don’t really know all that much about cryptocurrencies. I knew about Bitcoin and Ethereum but really didn’t really invest any time and money into looking at these growing forms of value exchange.

But now I’m a little curious.

I thought it would be fun to see what the value of XRP was against a fairly standard metric like the USD and keep a record of this exchange rate daily over a month or so (Mrs Yagi just read the ‘fun‘ in the last sentence and rolled her eyes).

I also thought it would be pretty cool to see how many exchange providers (Gateways) that conduct USD-XRP exchanges are around and see if there is much difference their exchange rate day-to-day among them.

Fortunately for me, the XRP Ledger provides a freely available open-source ledger that can be accessed via the Ripple Data API. The API can return JSON objects from which we can extract the data we need.

Of course, to record and display the daily exchange-rates I went straight to Google Sheets. I gathered the relevant XPR data using Google Apps Script’s UrlFetchApp Class and pushed it to my Google Sheet with SpreadsheetApp Class.

Here is a live embed of the XRP Google Sheet that is updated via a daily time trigger via Google Apps Script.

Continue reading “Google Apps Script – URL Fetch JSON data from an API and add it to a Google Sheet – Ripple API example”

Google Apps Scripts: Create Time Triggers to automatically send email task reminders from a Google Sheets check list

Google Apps Script: Time Triggers, ClockTriggerBuilder, ScriptApp

One of the most powerful things about Google Apps Script is the ability to automatically complete tasks with time-driven triggers. You can set up your code to run any one of your functions in your script by the minute, hour, day, week, or month. You can even set it to run based on a specific date.

Have a look at the time-driven trigger options below:

    • Specific Date and Time: Based on: YYYY-MM-DD HH: MM format
    • Minute: Every minute or every 5, 10, 15 or 30 minutes.
    • Hour: Every hour or every 2, 4, 6, 8 or 12 hours.
    • Day: At a time within an hourly bracket. For example:
      • Midnight to 1 am,
      • 3 pm to 4 pm
  • Month: On a specific day of a calendar month at a specific time. For example:
      • Every 3 day of the month at between 3 am and 4 am.

There are two approaches to setting up these time-based triggers. The first one is by simply using the Trigger creator inside the G Suite Developer Hub. This allows you to select the function that you want to add a trigger to for your project and fill out a simple form to determine when you want your trigger to run.

Gsuite Developer hub time trigger

Alternatively, you can create a time trigger programmatically using the ClockTriggerBuilder class.

In this tutorial, we will build on a previous project we’ve called The Badger, that contains a task check off Google Sheet. If the user does not check off their sheet by the due date, then we can send them an HTML email reminder.

Google Apps Script email remind from Google Sheet The Badger 2

Don’t worry, I will provide the starter code and the Google Sheet for you in a minute. However, if you want to learn how I created the email reminder for The Badger you can follow the tutorial here:

Google Apps Script: Create an HTML email reminder service from Google Sheet data.

If you want to see how I created the Spreadsheet, you can check out this link:

Google Sheets: How to create a task completion check sheet.

Setting Up

Continue reading “Google Apps Scripts: Create Time Triggers to automatically send email task reminders from a Google Sheets check list”

Google Apps Script – Why isn’t my add-on showing up in the add-on menu when I test it? (Updated Feb 2022)

Google Apps Script – AuthMode

I mean, when I run it normally, it works just fine!

This is an interesting problem I came across recently when reviewing one of my Google add-ons.

The Problem

The issue was that when I ran my Google Apps Script add-on code normally – in my case, connected to a Google Sheet – the add-on would appear just fine in my add-on menu. However, when I tested the script as an add-on ( run >>> Test as add-on…), as installed for current user but not enabled, my app would not appear in the add-on menu.

If I were to publish this app in this condition (and I may have…eep!), the user would be able to see my add-on in the add-on menu but not be able to access the link to run the app’s function without going into Add-ons >>> Manage add-ons… then click on Manage >>> Use this add-on. The user would have to do this each time they want to apply my add-on to a new Google doc for the first time. Not a good user experience.

The reason is that the first time the app is run in a new document, the Authorization Mode is set to none:

AuthMode.NONE

When the user opens the document for the first time, the onOpen(e) trigger function is loaded along with any global variables that are in the script.

This is what Google Apps Script has to say about this:

Google Apps Script onOpen AuthMode None
Source: Add-on Authorization.

So the problem was that one of my Global Variables did not abide by the scope of AuthMode.NONE.

How about we look at some example code to see how to identify the problem and work towards a solution.

Continue reading “Google Apps Script – Why isn’t my add-on showing up in the add-on menu when I test it? (Updated Feb 2022)”