AppsScriptPulse

Things one can get used to for the V8 Google Apps Scripts engine

A bit of a monologue about various syntax changes and adjustments in learning and using the tool.

Great post from Adam Morris (@clssrmtechtools) aimed at Google Apps Script developers wanting to start coding with the more modern JavaScript syntax used in V8. Adam shares lots of great advice to get started and build upon.

Source: Things one can get used to for the V8 Google Apps Scripts engine

Google Apps Script V8 variable scopes – var, const and let – Desktop liberation

One of the key things that V8 has sorted out is the scope of variables. Using var to declare variables meant that anything declared within the scope of a function could easily be accidentally overwritten, causing hard to track down errors. ES6 (since it’s commonly known as V8 in Apps Script – I’ll be referring to it as V8 from now on), has added const and let to the variable declaration vocabulary to help prevent these kind of problems.

With the introduction to the new Google Apps Script V8 runtime new opportunities are available for writing clean and robust code in the script editor using modern JavaScript syntax. In this post from Bruce Mcpherson you can learn some of the basics of var, const and let.

Source: JavaScript V8 variable scopes – Desktop liberation

Logger Drop-in Replacement for V8 Runtime

Why not make it a proper library? Because to make it a drop-in replacement, needs to have access to global scope, which a library doesn’t.

The V8 runtime changes how the Logger class works, which has shown much slower load times for simple Logging statements. This snippet writes all Logger.log calls to a spreadsheet when invoked, greatly speeding up development time.

Source: classroomtechtools/modularLibrariesV8

TeslaGAS is a Google Apps Script library that helps writing scripts for your Tesla car

Photo by Afif Kusuma on Unsplash

Photo by Afif Kusuma on Unsplash

TeslaGAS is a library that helps writing scripts that communicate with your Tesla – Zzapps/teslagas

Riël Notermans from Zzapps has published the beginnings of a nice little Google Apps Script library that you can use to communicate with your Tesla car.

Source: Zzapps/teslagas

Unit Testing in GAS Part 5: Testing Objects and Arrays

It’s time to dive into deeper equality situations with objects and arrays. Every test we’ve written so far has used a non-strict comparison. In other words, we’ve only been checking value but not type. This is particularly important in JavaScript because of how it handles truthy and falsy values.

The fifth part of a series using the GAS QUnit library to write unit tests for Apps Script projects in the web editor. This post details testing arrays and objects.

Source: Unit Testing in GAS Part 5: Testing Objects and Arrays

Bulk add unique data to an SQL Table in Apps Script

The following code combines Google Apps Script and SQL to bulk insert a Google Sheet of data into an existing SQL Table, but only after checking the record does not already exist so that it can be safely re-run.

Source: The Gift of Script: Bulk add unique data to an SQL Table in Apps Script

Email scheduler for Gmail – overview

Email scheduler spreadsheet columns image

Email scheduler spreadsheet columns

Over the next few blog posts I look to explore my development of an email scheduler for Gmail that is designed to let you schedule when you want an email composed in your drafts to be sent (by specifying the date/time).

This was written prior to Google introducing an email scheduler themselves.

Source: The Gift of Script: Email scheduler for Gmail – overview

Automating Academic Reviewer Finding With Microsoft Academic and Google Apps Script

One of the big problems today is finding reviewers. Editors are limited by their own knowledge and various publicly-available datasets (such as Google Scholar, Web of Science, and discipline-specific tools like philpapers.org or thephilosophypaperboy.com), and while especially these latter are useful, they are not tailor-made for reviewer finding. This setup presents a way to speed up peer-review by partially automating finding reviewers for academic papers.

The aim here is to make something that is tailor-made for reviewer finding, that works by taking data from one publicly available dataset (namely that of Microsoft Academic, which is basically Google Scholar but Microsoft), extracting from it a list of possible reviewers, creating a database from that, and letting one query this newly created database to find reviewers for a paper under your editorship.

Source: Automating Academic Reviewer Finding With Microsoft Academic and Google Apps Script

Loop delete specific rows with counter

Example table with specific rows to delete

Example table with specific rows to delete

Table with row 3 now deleted and data shifted up

Table with row 3 now deleted and data shifted up

The following Google Apps Script has been created to help with a recent difficulty I was having with deleting rows containing a specific value, where the loop was losing the row position due to the spreadsheet data all shifting up a row each time one was deleted. Some searching online suggested looping through a spreadsheet in reverse (from bottom up) to avoid the shift, but that seems more like a workaround than a direct solution …

Source: The Gift of Script: Loop delete specific rows with counter

Data Validation – check for blank cells

The following Google Apps Script code was developed as a tool to check that all the necessary data existed in a spreadsheet before another function was triggered. The reason for this was that if any data was missing it would affect the student Group files I was creating (eg no email address or name) that would eventually prevent further functions from running at a later date.

Source: The Gift of Script: Data Validation – check for blank cells