AppsScriptPulse

Google Apps Script snippet for Google Sheets to view json strings in a modal dialog

View json strings in a modal dialog

View json strings in a modal dialog. Activate the cell that contains a JSON string Click menu item A foldable JSON will be shown in the modal dialog

Handy little Google Apps Script snippet from Riƫl Notermans (Zzapps) that makes it easier to view any JSON you are storing in a Google Sheets cell.

Source: Zzapps/google_sheets_json_viewer

5 Google Sheets Script Functions You Need to Know

Google Apps scripting is a background scripting tool that works not only in Google Sheets but also Google Docs, Gmail, Google Analytics, and nearly every other Google cloud service. It lets you automate those individual apps, and integrate each of those apps with each other.

Source: 5 Google Sheets Script Functions You Need to Know

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

iterate ~80x faster through spreadsheet using map function in apps script

use array map method instead of “for” loops to iterate faster through 2-dimensional spreadsheet data.

Sourabh Choraria shares his experience of using Array.map to find values in a Google Sheet and the performance benefit of using this approach.

Source: iterate ~80x faster through spreadsheet using map function in apps script

Bulk save emails from Gmail

Screenshot of setup sheet for tool.

Screenshot of setup sheet for tool.

This tool is designed to bulk save emails (and associated attachments) from a specified Gmail label into a Google Drive folder, with relevant threads combined into a single PDF document.

Source: The Gift of Script: Bulk save emails from Gmail – overview

Log actions performed by a user running a Google Apps Script

Screenshot of spreadsheet with logs from script

Example log output from script to spreadsheet

A standalone function that you could include in your scripting projects to help determine which user ran a script and what actions it has performed. It is designed to output the information into a Google sheet – Date/Time, User, Action.

Source: The Gift of Script: Log actions performed by a user running a script

Convert Doc to PDF and move into a new folder with Google Apps Script

Create a PDF version of a Google Doc, move it into a new folder, remove its parents so it only exists in the new folder (typically also exists in My Drive) and then trash the Doc.

Source: The Gift of Script: Convert Doc to PDF and move into a new folder

Check if a date is more than a month ago

Recently during a consultation I was asked if it would be possible to check if the date submitted on a Google form was over a month ago, to which I responded “sure …”.

Admittedly this was a lot more difficulty than I thought it would (and should) be – I was bamboozled by online forums and posts suggesting to convert dates into numbers and perform other incoherent functions to achieve this. Eventually however I came across the single JavaScript function that I would need to achieve this feat …… ‘getMonth’.

Source: The Gift of Script: Check if a date is more than a month ago

Protect a named range in a Google sheet

The following Google Apps Script code is from some recent learning I have been doing when asked about locking-down certain areas of a sheet. I knew of named ranges and protecting cells but not quite that it could be done with apps script.

Source: The Gift of Script: Protect a named range in a Google sheet

SpreadAPI: add REST API to any spreadsheet in Google Sheets

SpreadAPI

Image: spreadapi.com

SpreadAPI is a free Google Apps Script that allows you to add REST API to any spreadsheet in Google Sheets in a few minutes. The API can be accessed over HTTPS from back-end as well as front-end apps.

It’s currently possible to publish a Google Sheet as JSON to get the data in a third-party application, but it’s harder to allow for posting new data back to that sheet. SpreadAPI is a script that creates a full-function REST API for a Google Sheet. Each implementation is set up individually and provides multiple authentication methods for specific users or even anonymous users.

Source: spreadapi.com