AppsScriptPulse

Using Google Sheets via BigQuery from Google Apps Script with service accounts

I’m using the JSON API for BigQuery rather than the Apps Script advanced service, since I have centralized all my BigQuery datasets in one project, and want to use a Service Account for authorization

Google Apps Script includes an Advanced service to interact with BigQuery. A limitation with both the Workspace services and Advanced Services don’t play nice if you need to use a service account. This post from Bruce Mcpherson provides details of how you can setup your Google Apps Script project to use a service account with BigQuery.

Source: Using Google sheets via Bigquery from Apps Script – Desktop Liberation

Autofill Google Sheet Formula with Google Apps Script

Use Google Apps Script to Autofill a formula down rows in a Google Sheet.

Autofill Google Sheet Formula

Autofill Google Sheet Formula

The following Google Apps Script is designed to insert a formula into the first row of data in a Google Sheet, then use Autofill to add the formula to the subsequent rows below. In this example I am just using a simple Sum formula to add up age and shoesize for demo purposes. The need to do this came about when combining multiple Google Sheet files however, that needed calculations adding to the final composed version.

Source: The Gift of Script: Autofill Google Sheet Formula

Google Apps Script library if you need to get a Google Sheet as a PDF

Library for converting Google Sheets Into PDF

Features:

  • All PDF settings including colontitles = custom headers and footers.
  • Input parameters is a single plain object.

The library uses the printing features of Google Spreadsheets to provide a complete representation of a document in a different format. It contains a huge amount of features There are settings such as page size, headers and footers, colontitles, gridlines, notes and more.

Source: Max-Makhrov/sheets2pdf_gs: Library for converting Google Sheets Into PDF

Clearing cells in multiple Google Sheets using Google Apps Script

This is a sample script for clearing the discrete cell values on multiple sheets using Google Apps Script.

Handy little code pattern for clearing ranges across multiple tabs in Google Sheets. Snippets are provided for both SpreadsheetApp and the advanced Sheets service.

Source: Clearing Discrete Cell Values on Multiple Sheets using Google Apps Script

If you use clasp with Google Apps Script, you need this environment switching utility right now!

When working in a team and/or with a client, you want to have multiple environments. At minimum, you probably want a dev environment (or multiple ones) in which you are working, and a test environment in which the client or your team can run acceptance tests before production. Of course, they must both be separate from the production environment. To push your code to the correct environment, you need to either update the .clasp.json file manually or keep multiple copies of your script with different .clasp.json files. Fortunately, things have just become significantly easier, as I recently built an app for this purpose called clasp-env, which is available on NPM. See the source link for details.

Source: “If You Use Clasp With Google Apps Script, You Need This Utility Right Now”

Using Google Apps Script to convert a Google Sheets selected range to an image 

Convert selected range into PNG image and save it to Drive

In this post from Max Makhrov you can discover how you can convert a selected Google Sheets range to an image. With options to embed charts and tables in Google Docs and Slides you might be asking why you would want to do this. Max highlights a couple of great reasons:

There are some limitations with this approach which are outlined in the post and if you have any solutions there is a link to contribute to the GitHub repo.

Source: Google Sheets Script. Range 2 Image

How to track link clicks in emails and more with Google Apps Script and Google Sheets

Learn how to track link clicks using Google Sheets and Apps Script to create a simple, lightweight tracking system

You live and learn! This is a regular occurrence if you are a subscriber to the work of Ben Collins (benlcollins.com). No exception with this recent post highlighting the ping attribute which can be used in <a> HTML links. This attribute has been around for a long time, but I’m sure many people like have never come across it. In the source post from Ben you can learn how to setup an Apps Script web app which will let you record link clicks in a Google Sheet.

A note of caution is whilst ping is valid HTML not all browsers choose to use it or enable it by default, something Mozilla have decided to do in Firefox. You can head over to Mozilla mdn documentation for the browser compatibility table and here is also an interesting post on how Google tracks with the ping-attribute.

Source: How To Track Link Clicks With Apps Script And Google Sheets

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