AppsScriptPulse

Create automated backups of Google Sheets with Google Apps Script

The problem comes when you have to load that info in your app. … The more the data, the more time to load. You could use Apps Script to schedule backups of your data.

A nice introduce into Google Apps Script with an opportunity to learn how to archive data from one Google Sheet to another. This solution comes from Mozart GarcĂ­a who is more often seen on YouTube producing short Google Apps Script how-to in Italian (Bravo! Mozart on recently passing 4K subscribers)

Source: Create automated backups with Apps Script

Using Google Apps Script to get Google Workspace user profile pictures without using the Admin APIs

Image credit: Google

Chances are that you may need to display user’s picture profiles in your applications. However, this API is part of the Directory API, which is part of Google Workspace Admin area. And chances are that your Organization has simply not giving you the rights to use Admin APIs

Sometimes within your Google Workspace domain you’d like to include account profile images. A number of Google Workspace APIs, like the Drive API, will include profile pictures in the response object. When this isn’t the case this post by Turhan Oz is a nice reminder that the dedicated People API can be used to get profile images. Click through to the source post to read more and sample code.

Source: AppScript — get user profile picture without using Admin APIs

How you can use Google Docs to write and execute Google Apps Script code

Image credit: Amit Agarwal (labnol.org)

There is a way to use Google Docs as a programming IDE and run JavaScript code inside the editor …  It is no replacement for a dedicated IDE like Visual Studio code but Google Docs can be used as a JavaScript playground to quickly run code snippets.

A familiar story I hear is people with no formal coding experience starting their developer journey with Google Apps Script. I find being able to run small snippets of code are a great way to learn and a number of sites like W3 Schools and also increasingly Stack Overflow include the ability to ‘try it yourself’ with inline code runners.

If you are looking to support users getting started with Google Apps Script Amit Agarwal has this little code snippet which lets you inline/run Google Apps Script code in Google Docs. There are both limitations and considerations with this approach but as a quick way for learners to run and collaborate on small snippets, which can be contextualised with explanatory text/resources, it’s a nice starting point. Check out the source link for more details.

Source: How to Use Google Docs as a Code Runner – Digital Inspiration

Uploading multiple records with the Salesforce API using Google Apps Script

Image credit: Eduardo Ramon Resser

Sometimes, when using Salesforce, we come across the situation of needing to upload several object records at once, such as accounts, contacts, tasks, etc.

There are several ways to resolve this issue. One approach that can be efficient is through Google Sheets, especially if you want to “convert” each row in a table into separate records in Salesforce.

In the example of this article, I will talk about an implementation for bulk exporting of tasks using information contained in a table in Google Sheets using the Salesforce API.

This post on interacting with the Salesforce API highlights the tricky situation of handling different user credentials. The author comes up with a clever solution of using user owned Google Docs as a way to store different identities. Another approach is to use Google Apps Script’s Properties Service. The Properties Service includes an option to store User Properties which are only accessible to the user running the script.  The downside of this approach is you then have to create UI for the user to input properties.

Source: Uploading Multiple Records Via Salesforce API Using Google Apps Script

Import CSV data into Google Sheet using Google Apps Script

Loop through CSV files in Google Drive and extract their contents into specific areas in Google Sheet files.

CSV File template to copy data into

CSV File template to copy data into

The following Google Apps Script is designed to loop through a folder of CSV files in Google Drive, extract the data, create a Google Sheet file per CSV, and insert the data into specific rows/columns.

Source: The Gift of Script: Import CSV data into Google Sheet files

How to create a Trello card using Google Apps Script

If you are a Google Workspace and Trello power user like me, I’m sure the thought has come across your mind of connecting your Google Apps to Trello, but every time you search for a solution you get an ad for Zapier or IFTTT. I try to avoid these solutions because they are great at making an initial connection, but if you ever want to do anything advanced, it will require you to sign up for a premium subscription. After searching and not finding answers, I decided just to try and build it for myself.

If you are a beginner to Google Apps Script this is a nice tutorial if you are interested in learning about connecting with other services, in this case Trello. Hopefully this post also illustrates that coding aspect of connecting with other services using Google Apps Script can be straightforward once access had been setup on the third party site.

Source: How To Create a Trello Card from Apps Script

An automatic random team maker using Google Apps Script

In this post, we’re going to look at a script to be able to make even teams from a selection of players. I play football every Sunday and every week my friends sign up to play and most weeks there are different players playing, so we end up having to make the teams, and trying to do it as fairly as we can, which inevitably takes some time.

Nice ‘weekend project’ from Baz Roberts highlighting how Google Apps Script can be used to do a weighted random shuffle of data. The post includes a line-by-line explanation of what the script is doing and a great resource if you are at the beginning of your Apps Script journey.

Source: Automatic Team Maker — Apps Script (also available on bazroberts.com)

Efficient file management using batch requests with Google Apps Script 

Google Drive alone can handle small file management jobs, but for larger batches of files, it can be too much for a simple Drive script to manage. With Google Apps Script, even large batches can be executed within 6 minutes, offering businesses the monetary and time benefits of efficient file management. This report looks at how Google Apps Script improves file management with batch requests, judging its efficacy by measuring the benchmark.

We’ve regularly highlighted work from Kanshi Tanaike in Pulse and it’s nice to see it also being highlighted in the official Google Cloud Blog. I’m sure many Google Workspace developers, like me, have encountered issues with managing large volumes of Google Drive files. In the post Kanshi Tanaike highlights how batch methods can be used to greatly speed up the process when interacting with the Google Drive API.

Source: Efficient File Management using Batch Requests with Google Apps Script | Google Cloud Blog

Reading Qualtrics survey details with Google Apps Script

Use the Qualtrics API to connect with a Survey and get its details.

Qualtrics API Survey details

Qualtrics API Survey details

Most of the complexity with this simply comes in getting the correct syntax for connecting to the Qualtrics API. This Get Survey Qualtrics webpage provides a little bit more technical detail for what exactly is sent/received.

You will need to complete the 3 pieces of information at the top of the Apps Script code for your own setup:

  1. API Token from the Qualtrics website,
  2. ID of the Survey you want the details of,
  3. Your Data Center ID.

Source: The Gift of Script: Get Qualtrics Survey details

Google Chat Apps for Google Apps Script Developers

In this article, we will look at Google Chat Apps and go over some of the basics of developing a chat app with Google Apps Script.

Scott Donald provides a comprehensive overview of everything you need to know to get started with Google Chat app development with Google Apps Script.

One of the nice things about Google Chat app development is there are a number of different implementation architectures you can use, including Google Apps Script. Regardless of the architecture you choose there are some common steps such as GCP setup, receiving/responding to messages and using dialogues and card interfaces all covered in Scott’s post. Click through to find out more…

Source: Google Chat Apps for Google Apps Script Developers – Yagisanatode