AppsScriptPulse

Introducing ‘Twitter for Google Chat’ – a Chat app built using Apps Script

Preview tweets and user data when sharing links, along with the ability to follow a specific user or like a particular tweet.

If you haven’t looked at Google Chat apps or not looked at Chat apps for a while this is a great post from Sourabh Choraria outlining the development process using Google Apps Script. As part of this Sourabh includes an overview and source code for a Twitter powered Chat app recently published and available to try out in your Google Workspace domain. The app showcases slash commands as well as a recent new feature of preview links.

Source: Introducing ‘Twitter for Google Chat’ – a Chat app built using Apps Script

Enhanced inline markdown commenting in Google Apps Script functions using JSDoc

Another useful discovery from Kanshi Tanaike this time highlighting the ability to use markdown in Google Apps Script code comments. For those unfamiliar, JSDoc is the syntax used to automatically generate inline documentation in Google Sheets custom functions, Libraries as well as function references in your script project. As highlighted in the post as well as being able to add @constructor tags, developers can use markdown syntax to provide additional formatting to documentation comments. See the source post for details of supported markdown syntax.

Source: Report: Documentation Comments including JsDoc for Functions of Google Apps Script

Create an Out Of Office event in Google Calendar with Google Apps Script

🏝 It’s finally summer break! We all wish we could create Out Of Office events in Calendar using Google Workspace #AppsScript (I know you do). But Calendar API is yet not allowing us to do so.

This post from Dararath BEAUVOIR is a great reminder that in Google Workspace/Apps Script development that you occasionally need to look beyond the built-in services like CalendarApp to the Advance Service equivalents. In this case Calendar.CalendarList.list is used because unlike CalendarApp using the Advanced Service the event response indicated if the eventType is out-of-office. More details are included in the source post.

Source: Create an Out Of Office event in Calendar with Google Apps Script

GWAOw! 4 – Forms History a Google Forms Add-on by Martin Hawksey

Forms History is a Google Workspace Add-on that allows you to monitor your version history and store copies in Google Forms

Not just talking the talk, but also walking the walk. Shortly before taking a new role at CTS, the largest dedicated Google Cloud Partner in Europe, I published Forms History an add-on to enable revision history functionality in Google Forms.

Fellow Google Developers Expert, Scott Donald, has picked this up in the latest episode of GWAOw! his dedicated to Google Workspace Add-on review show. You can follow the source link for the YouTube clip and more. As part of the episode Scott rightly highlights the creative work of Alice Keeler, which hasn’t just included artwork but Alice has also provided a huge amount of support in promo and usability.

If you are interested in the inner workings of Forms History there is a related post on Working with the Google Drive API Revisions history: Tips for handling revision merges with Google Apps Script.

Source: GWAOw! 4 – Forms History by Martin Hawksey – Yagisanatode

Programmatically manage and apply Drive Labels using new API functionality

Many of our customers already take advantage of the Drive Labels capabilities to classify content and implement policies on their Drive files for governance and Data Loss Prevention.

Today, we’re happy to announce a highly requested update that will enable you to programmatically manage labels at scale via Drive APIs.

Google Workspace devs might be interested in this update to the Drive Labels API which enables additional functionality. As noted in the source post:

The new Drive Labels API supports reading Drive Label taxonomies. New functionality in the Drive API can be used to apply labels, set fields on files, and find files by label metadata. As a whole, these new API features enable numerous use cases including, bulk-classification, Apps Script driven workflows, third-party integrations, and other organizing and finding needs.

The post includes links to a number of useful resources including reference documentation.

Source: Programmatically manage and apply Drive Labels using new API functionality

Benchmark: Process cost for Parsing XML data using Google Apps Script

Note: Process time has been graphed on a log scale

In order to retrieve the values from XML data, when XML data is parsed using Google Apps Script, there are several methods for parsing the data. … For example, Class XmlService cannot only parse and read XML data but also update XML data and create new XML data. In the current stage, the process cost of Class XmlService is much higher than those of “cheerio” and the simple script using regex.

In Pulse we’ve previously highlighted the cheerio JavaScript library for parsing/extracting content from XML data. The cheerio library can easily be added to Google Apps Script projects as a library (see the GitHub repo for installation). Google Apps Script also has the XML Service, which can also be used to work with XML data. In this latest benchmark report from Kanshi Tanaike they look at the process cost for reading XML data using XML Service, cheerio and using RegEx. The results highlight a higher process cost for using XML Service particularly if you are handling reading 1,000 or more XML elements. The source post contains further details of the test and a summary of the results.

Source: Benchmark: Process cost for Parsing XML data using Google Apps Script

Dependent dropdown lists for Google Sheets (and lots of other Google Apps Script goodies)

Updated the script for dependent lists, and now it supports new options. New for 2022:

Dependent drop-down lists can be used to create a dynamic list of choices in Google Sheets. When the user makes a selection from the first drop-down list, the choices in the second drop-down list will be updated based on the selection. This can be used to create a cascading list of choices.

If you are looking for a nice solution to build dependent drop-down lists in Google Sheets this is a great solution from Max Makhrov. For more experienced Google Apps Script developers the solution incorporates some clever snippets both from Max and a number of other members of the community. Some highlights include: converting a column index into corresponding column letter; a tasker to batch apply updates to a Google Sheet; ChuckyCache for objects above 100Kb; and a reference to a zip compression solution. All these are referenced in the source code provided in the post.

Source: Dependent Drop-Down Lists For Google Sheets v2022

Automatically backup Google Drive folders to Cloud Storage with Google Apps Script

Image credit: Stéphane Giron

Few days ago, with the launch of French region ‘europe-west9’ in GCP, I made an apps script to backup a Drive folder to Cloud Storage. It is a cool script and works nicely but after some exchange, we can make it better.

So here I come back with onleebackup an open source code to backup multiple Google Drive folders to cloud storage with synchronisation.

A very interesting open source project from Stéphane Giron which lets you backup Google Drive folders to Google Cloud Storage. An important caveat is with Google Apps Script limitations like script runtime and URL Fetch POST size this won’t work if you have gigabytes of data. The code has some nice features like handling Google Docs/Sheets/Slides file types, converting them to equivalent MS Office formats as well as management of Google Drive shortcuts, which requires calls to v3 of the Google Drive API. The source post provides details for setting up onleebackup, which also includes a link to a previous post with code highlights.

Source: Automatically backup Google Drive folders to Cloud Storage

Benchmark: Process cost for HTML Template using Google Apps Script

Image credit: Kanshi Tanaike

When we use HTML in the Google Apps Script project, in order to show the values from the Google Apps Script side, the HTML template is used. When I used the HTML template with a large value, I understood that the process cost can be reduced by devising a script. In this report, I would like to introduce the process cost of the HTML template using the benchmark.

A great feature of Google Apps Script is the ability to create and serve custom HTML, often used to interface data you have in Google Workspace such as Google Sheets. Google highlight a coupe of different ways you can mix Apps Script code and HTML. Some of these ways are better in terms of process time and this report from Kanshi Tanaike highlights the cost of calling Apps Script functions as scriptlets in HTML templates. The good news is you can avoid delays in your web app rendering by making asynchronous calls with google.script.run, which you can read more about in Google’s best practices documentation.

Update: I’ve replicated this benchmark (smaller dataset) with google.script.run and it was only marginally slower (0.3s) than the ‘create HTML table with Google Apps Script’:

Source: Benchmark: Process cost for HTML Template using Google Apps Script

Working with the Google Drive API Revisions history: Tips for handling revision merges with Google Apps Script

Having spent quite a bit of time working with the Google Drive API Revisions resource in this post I thought it would be useful to share some of the lessons and solutions I’ve picked up along the way. For this I’ll be sharing code snippets for interacting with the Revisions resource with Google Apps Script, but the solutions discussed could easily be applied to your programming language of choice.

Source: Working with the Google Drive API Revisions history: Tips for handling revision merges