Well, well, well! Look who’s back for another session of “Weaving Magic with Code”! 😄 Today, we’re diving head-first into the magical world of unit testing. You might be wondering: “Why the fuss about unit testing?” 🤔
Unit testing, my friends, is the silent hero of software development. Picture it as a mini-pit stop where your code gets a once-over before it hits the road. The automated tests ensure that our code does exactly what we expect it to. The benefits?
Makes us ponder deeply about our app’s architecture, like a philosopher musing about the meaning of life 🧐
Forces us to clarify our expectations from functions and classes.
Ensures that as we revamp and update our code, we aren’t unknowingly playing host to bugs, much like a surprise party you didn’t want 🐛
Use a row of data in a Google Sheet to pass to a Google Doc via Apps Script
Create a Google Doc containing the information from a selected row of Sheet data.
The following Google Apps Script is designed to create a Google Doc for the selected row of data in a Google Sheet and to include some of that data within the new Doc. it also creates a link to the new Doc back in the Sheet on the relevant row.
I use Google Apps Script to support staff and students in my job. I enjoy dabbling with creating tools to help with automation and I freely share my learning experiences on my blog, where I also have a number of useful Google Add-ons: www.pbainbridge.co.uk
Conduct app monitoring, data backup, and data analysis for your MongoDB … This article shares a simple way to achieve this using Google Sheets and Apps Script. In this article, you will learn how to:
Populate MongoDB data in Google Sheets for analysis
Receive daily reports of your app’s growth metrics via email
Often the hardest part of interacting with other services using Google Apps Script is working out the payload you need to send with UrlFetchApp. Despite having almost 1,000 posts in AppScriptPulse, this is the first post featuring MongoDB. The source post has all the code and setup instructions to start collecting MongoDB data into Google Sheets as well as sending a daily email report of selected metrics.
Are you someone who loves reading blogs but finds it difficult to make time for them? Or, are you a blogger looking to make your content more accessible to readers? You’re in luck! I discovered an incredible combination of tools that can help automate the summarisation of blog posts.
Learn how to automate blog summarisation with Google Apps Script, ChatGPT, and OpenAI API. This blog post by Aryan Irani guides you through the process, enabling you to enhance your content creation efficiency. Simplify summarisation and maximize productivity in just a few steps.
Aryan Irani is a Google Developer Expert for Google Workspace. He is a writer and content creator who has been working in the Google Workspace domain for three years.
The first step in conducting research involves acquiring an appropriate dataset. .. Apps Script is a scripting platform developed by Google, that provides a user-friendly interface that enables easy automation and interaction with various Google services, including YouTube’s API.
For many years I was custodian of TAGS, a Google Sheets solution to archive Twitter searches. This came to an abrupt end when Twitter put a hefty paywall on API access. I’m sure there were ‘bad actors’ using TAGS, but I was also aware there were a number of academics and students using this solution to help make the world a little better. As noted in this source post “Dataset plays a crucial role in ensuring the accuracy and dependability of the results we obtain”.
For social scientists looking for new datasets this post from Randie Pathirage highlights how you can use Google Apps Script to get comments on YouTube videos using the YouTube Data API.
Automatically create PDFs with information from sheets in a Google Sheets spreadsheet. Once the PDFs are generated, you can email them out directly from Sheets. This solution focuses on creating custom invoices, but you can update the template and script to fit your needs.
Today as part of a customer Google Apps Script introduction workshop, we covered a basic invoice / PDF example. By coincidence this month’s Google Workspace Developers Newsletter highlighted a solution spotlight from the Apps Script samples catalogue which does something very similar.
A trick I learned today from our Lead Workspace Trainer, Tim McLardy, was rather than using UrlFetchApp to get a PDF version of the Google Sheet with the export/?format=pdf url, is instead getting the Google Sheet as a blob and creating a pdf with DriveApp.createFile(). As this technique will generate a PDF with pages with all your Sheet tabs the trick is to selectively hide all but the tabs you want in your PDF. In the case of the example linked as the source post you can rewrite the createPDF() function as:
/**
* Creates a PDF for the customer given sheet.
* @param {string} ssId - Id of the Google Spreadsheet
* @param {object} sheet - Sheet to be converted as PDF
* @param {string} pdfName - File name of the PDF being created
* @return {file object} PDF file as a blob
*/
function createPDF(ssId, sheet, pdfName) {
// Based on https://webapps.stackexchange.com/q/162155/30021
const ss = sheet.getParent();
const sheets = ss.getSheets();
// Hides all sheets that are not the main one
sheets.forEach(s => {
if (s.getSheetName() !== INVOICE_TEMPLATE_SHEET_NAME) {
s.hideSheet()
}
});
// make a pdf of the sheet
const folder = getFolderByName_(OUTPUT_FOLDER_NAME);
const pdfFile = folder.createFile(ss.getBlob()).setName(pdfName);
// show all the sheets
sheets.forEach(s => s.showSheet())
return pdfFile;
}
Learn how to use the Udemy API with Google Apps Script to find free programming courses on Udemy on any topic.
A double win in this post from Amit Agarwal. Not only can you get a list of free programming courses currently running on Udemy, but Amit includes the code snippet used to get/add these to a Google Sheet. This might be useful if you are working with other APIs and are looking for a code snippet to help format the data in a Google Sheets friendly format.
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.
Imagine you’re responsible for transporting materials from one location to another for a logistics company. Accurately calculating the distance and time between two points is crucial for efficient logistics management, and having this information readily available can save time, money, and effort. However, doing it manually can seem like a daunting task. But don’t worry, there’s a solution!
Discover how to automate distance and time calculations between two points in Google Sheets using Google Apps Script. This blog provides a step-by-step guide on setting up the integration and shows you how to use it to save time and increase productivity.
Aryan Irani is a Google Developer Expert for Google Workspace. He is a writer and content creator who has been working in the Google Workspace domain for three years.
Welcome to the Ultimate Google Ultimate Google Apps Script Front-End Development Guide!
If you are reading this post, then you likely have experience with Google Apps Script. Essentially, there are three types of front-ends that you can create with Apps Script:
Web apps
Modal/modeless dialogues
Sidebars
In this blog post series, we will only discuss HTML front-ends, as this is where you can create the most powerful and sophisticated user experiences. Unfortunately, the Card Service is outside the scope of this series, and it is not nearly as powerful as an HTML front-end. With that in mind, Google, how about allowing HTML front-ends for Workspace add-ons?