AppsScriptPulse

How to highlight duplicate rows in Google Sheets with Google App Script

Highlight Duplicate Rows in spreadsheets efficiently and accurately with Google Apps Script for coders and non-coders.

Some nice techniques in this post which shows you how you can highlight duplicate rows in a Google Sheet using Google Apps Script. If you need to modify there is a isDuplicateRow() which could be modified to suit your needs. Another nice solution in this example is the inclusion of function to getRandomUniqueColor(), which returns a random hex colour.

Source: How to Highlight Duplicate Rows in Google Sheets?

Creating your own Google Calendar Assistant with Google Apps Script and the Google Speech to Text, ChatGPT and Google Chat APIs

 

Image credit: Stéphane Giron

Have you ever wished for a personal assistant who could give you a quick summary of your day’s events while you’re busy getting ready in the morning? I worked on a Google Apps Script that does just that! By collecting events from in Google Calendar, generating a summary using ChatGPT, and creating a voice file with Google Text to Speech, the script will send a daily summary straight to their Google Chat Spaces.

Not surprising given the current interest in generative AI to see more examples emerging from the Google Workspace developer community. This latest example comes from Stéphane Giron who shares how he is able to recreate some Google Assistant functionality with Google Apps Script and calls to the ChatGPT and Google Cloud Text to Speech services. All the main code snippets from this project are available in the source post link.

Source: How I created a Calendar Assistant with Google Apps Script that automates a daily voice summary…

Calculate contrasting font colors for Google Sheets with Google Apps Script

If you are playing around with Sheet colors with Apps Script, you sometimes find yourself with font colors that don’t go well with the background colors you’ve chosen. However, we can use Yiq values to decide whether the luminance of the background color would be best with a light or a dark foreground font color. Here’s a small Apps Script library to figure it out for you.

Nice little helper library from Bruce Mcpherson if you’ve like to automatically apply contrasting colours to Google Sheets ranges. The source post from Bruce provides the background to the YIQ colour system as well as how to use the library. Follow the source link for more details.

Source: Calculate contrasting font colors for Sheets. – Desktop Liberation

Generating a Time-based One Time Password (TOTP) in Google Apps Script

In this post, I would like to introduce a sample script for putting Time-based One-time Password (TOTP) value into Google Spreadsheet using Google Apps Script.

For UK readers, no not Top of the Pops (TOTP), but Time-based One Time Passwords (TOTP). In the context of Google Workspace it’s more than likely that you can rely on the built-in Google Identity and account security features rather than rolling your own form of two-factor authentication (2FA). Should you be in such a situation when you need to authenticate outside of Google then this example integration of the OTPAuth library in Google Apps Script might be of interest. Rather than just updating a Google Sheet you could combine with MailApp/GmailApp to email the passcode for the user to use. See the source post for implementation information and caveats.

Source: Putting TOTP into Google Spreadsheet using Google Apps Script

Automating the creation of multiple folders in Google Drive with Google Apps Script (with a nice Google Sheet processing code pattern)

 

you can use the following Apps Script to create folders in Google Drive for students and share those folders with their email addresses based on data from a Google Sheet

Whilst this post from Amit Agarwal looks at the automatic creation of Google Drive folders, it’s also worth having a look at it at for an Apps Script pattern for iterating over and processing data from Google Sheets. In particular there is a getStudentData()function that turns the 2D array return from .getValues() into an object array which includes a rowIndex. This makes it easy to update your Google Sheet when each row is processed.

Source: Automating the Creation of Multiple Folders in Google Drive – Digital Inspiration

Create Your Own “UptimeRobot” to monitor websites using Google Sheets, Gmail, and Google Chat

If you monitor important websites and require advanced features, tools such as UptimeRobot is the solution for you. However, if you only have a few personal websites and want a simple, customizable, and free alternative for monitoring them, this may be a better option.

In this tutorial, I will guide you through setting up a website monitor using Google Apps Script and Google Sheets. This monitor will periodically check the status of your websites and notify you via email and Google Chat (optional) if any issues are detected.

We’ve featured other website uptime solutions using Google Apps Script, this one is nice because it also includes an optional Google Chat integration allowing to send alerts your preferred Chat Space. Another useful feature, used by a number of paid for uptime monitors, is defining a keyword which must be found in the page. Follow the link to the source post for all the code and instructions on getting started.

Source: Tutorial: Create Your Own “UptimeRobot” to Monitor Websites Using Google Sheets, Gmail, and Google Chat

Setup automated reminders in Google Forms/Google Sheets with Apps Script

 

In this article I’ll show you how to setup reminder emails that will get sent automatically each day if there are any pending tasks in your spreadsheet. Stay tuned until the end, where I’ll show you an easier way to accomplish this using Coda.

Eric Koleda must be the undisputed master of the Apps Script demo. The ‘random cat’ Add-on, is one of my favourite examples where Eric finds a really simple hook to get you engaged in what can often be a complex project. Eric is now Developer Advocate at Coda and he’s not lost is eye. In this post Eric gives the gift of script with a basic example of how you can handle email notifications from Google Form responses in batches with a timed trigger (cats being replaced for cakes). Eric also shows how a no-code alternative can be accomplished in Coda.

Source: Setup automated reminders in Google Sheets

VisiCalc Returns! Tribute to VisiCalc inside Google Sheets made with Apps Script

Let’s jump off the new tech bandwagon and use 40 year old technology. VisiCalc, arguably the first spreadsheet software, is now available inside of Google Sheets. Just like it was installed on an Apple II. Enjoy the 80’s era, Chiptune-esque, 8 bit-ish VisiCalc emulator inside of Google Sheets.

For those not around in 1979 VisiCalc was the first spreadsheet computer program for PCs. There is a great Wikipedia article with information about VisiCalc which highlights:

VisiCalc is one of the earliest examples of metaphor-driven user interface design, due to its resemblance with paper spreadsheets. Compared to paper spreadsheets, VisiCalc freed users to change numbers without having to recalculate the whole spreadsheet by hand, which, according to Steven Levy, “changed the perception of a spreadsheet from a document of hard costs into a modelling tool by which one tested business scenarios”.

Andrew Kamphey at Better Sheets has faithfully recreated a number of features from VisiCalc in Google Sheets. You can find out more about VisiCalc 2023 on its Product Hunt page or make a copy from BetterSheets.co/visicalc.

Having a play with VisiCalc 2023 my immediate thought is why doesn’t Google Sheets have a native dark mode on desktop devices. Just one of the many things they got right is 1979. Andrew has included some other lovely touches including a product serial number (remember to keep this in a safe place), and a print command.

If you are on Twitter and would like to share your VisiCalc memories or reflections headover to this thread.

Source: VisiCalc 2023 – Tribute to Visicalc inside of Google Sheets | Product Hunt

How to efficiently read email messages with the Gmail API and Google Apps Script batch requests

There are two ways to pull email addresses from Gmail messages. The simpler, and more popular, method is that you pull a list of messages from which you wish to extract the email and loop over them to extract the email addresses. A more efficient way to pull email addresses from multiple email messages is to make a single batch request to the Gmail API with the help of Apps Script’s UrlFetch service.

We’ve featured a couple of posts on how you can make batch requests with Google Workspace APIs. With the limited runtime in Apps Script using batches can be an invaluable tool to finish your script in the execution limit and also improve your user experience. In this particular example for Amit Agarwal he looks at how batch requests can be made to the Gmail API by first get message details from a call to Gmail.Users.Messages.list, before getting message details in a single UrlFetchApp.fetchAll call. All the example code is included in the source post and to get to execute it copy/paste/run the following function:

const app = () => {
  const messageIds = searchGmailMessages();
  makeBatchRequest(messageIds);
}

Source: How to Efficiently Read Email Messages with the Gmail API and Apps Script – Digital Inspiration

Automate invoice management in Gmail with Document AI and Google Apps Script

Image credit: Full diagram of invoice automation in Gmail with Document AI and Apps Script –
Stéphane Giron

Tired of manually managing your invoices in Gmail? Say goodbye to the hassle and hello to efficiency with Document AI and Apps Script.

There is a lot of buzz around generative AI, but it’s also worth remembering Google have a well established service offer in other forms of AI, the Document AI being one example of this. This post from Stéphane Giron highlight an Apps Script based workflow for analysing invoices attached to Gmail messages using the Document AI. There is a bit to setup in a Cloud project to get this working and as a paid for service costs to consider. Further information on this and all the code you need to get started are included in the source post.

Source: Automate invoice management in Gmail with Document AI and Google Apps Script