AppsScriptPulse

Sort by Random – How to Randomize the Order of Rows in Google Sheets – Digital Inspiration

Learn how to sort your data in a Google Sheet in randomized order using Excel formulas and Google Apps Script.

Nice little snippet from Amit Agarwal which includes some Google Apps Script code for randomising the order of rows in Google Sheets. The code has some clever use of .autoFillToNeighbor(), .offset() and .sort().

Source: Sort by Random – How to Randomize the Order of Rows in Google Sheets – Digital Inspiration

Using Google Apps Script to find/print inactive users in Google Workspace – xFanatical

In large organizations, it’s overwhelming for admins to find inactive users in the User List of Google Admin Console. These inactive users have not been logged in their Google accounts for a long period. It imposes a potential security risk to the organizational data if these accounts are not taken care of.  A free apps script to print all inactive users in Google Workspace. The following open source Google Apps Script can automate the process of printing inactive users in your domain.

Nice little snippet from xFanatical. Check out the source link for all the code and instructions for using.

Source: Print inactive users in Google Workspace – xFanatical

Check/uncheck the entire checklist in Google Docs with Google Apps Script

Currently it is unknown if the checklist can be manipulated in Docs. Clark Lind suggests to replace a list item with a copy of one of them (which is in expected state – check/uncheck)

A nice example of the Google Apps Script developer community helping each other out. In this case Alexander Ivanov was looking for a way to interact with the new Google Docs checklist feature. A direct way to interact with these isn’t possible but some clever coding from Alex demonstrates what is currently possible.

Source: Uncheck a checklist

XPath Tester using Web Apps Created by Google Apps Script (working with existing Google Sheets functions in Apps Script)

In this post, I would like to introduce the xpath tester using Web Apps created by Google Apps Script.

This is an interesting little Apps Script solution from Kanshi Tanaike which uses the existing Google Sheets =IMPORTXML() in a Google Apps Script  Web App to test an XPath. As there is a delay in loading some Google Sheets function results this post includes a nice little coding pattern using a do...while loop to wait for results to render.

Source: XPath Tester using Web Apps Created by Google Apps Script

Bulk create Sheets from a Google Sheet

Use Google Apps Script to bulk create Sheets from a Google Sheet of data. Loop through each row and copy the data to the new file.

Bulk create Sheets from Google Sheet

Bulk create Sheets from Google Sheet

Source: The Gift of Script: Bulk create Sheets from a Google Sheet

How to Change the Font in your Google Documents with Apps Script – Digital Inspiration

How to change the font family and font styles of multiple Word documents in your Google Drive with Apps Script. This example show how to replace the font family of your Google Documents of specific sections – the heading titles are rendered in a different font while the tables, list items, body and table of contents are formatted with a separate font.

Source: How to Change the Font in your Google Documents with Apps Script – Digital Inspiration

Bulk create Shared drives with permissions

Bulk create Google Shared drives with permissions all from a Google Sheet.

Bulk create Shared drives from a Google Sheet

Bulk create Shared drives from a Google Sheet

  • Provide the name of the Shared drive on each row in column A.
  • Provide the email address(es) of the Google Account(s) under the relevant Access level column (Manager, Content Manager, Contributor, Commenter, Viewer). Use a comma and a space to separate multiple email addresses, eg: [email protected], [email protected], [email protected].
  • Ensure you include at least one Manager – the script will check for this – so as to prevent creating a Shared drive that you are then unable to access.
  • On the ‘Config’ sheet provide the column numbers – leave the default values unless you change the structure of the ‘Data’ sheet and move columns around.
  • The ‘Log’ sheet should help to troubleshoot any errors you experience, but there will also be a popup message should the script fail at some point.

Source: The Gift of Script: Bulk create Shared drives with permissions

Get the difference between dates in minutes

The following Google Apps Script is designed to get the difference (in minutes) between 2 dates from a Google Sheet. This was part of a tool used to create events from data in a Google Sheet where I needed to get the duration of the meeting for Zoom. The actual date, hour and minute values are separated in columns as it was easier to control user input in that format, so we will need to piece them together.

Start and End date values in a Google Sheet

Start and End date values in a Google Sheet

Source: The Gift of Script: Get the difference between dates in minutes

Set permissions on a Shared drive with Google Apps Script

The following Google Apps Script is designed to bulk set permissions on a Shared drive. It has been created as a standalone Function that requires the ID of the Shared drive and manually entered email addresses for the relevant permissions.

This is how I first worked with it to learn what information was required and how to structure the content, before combining it all into a Google Sheet tool which will be blogged about in the near future.

Source: The Gift of Script: Set permissions on a Shared drive

Generate a quick unique(ish) value

Generate a quick, random and fairly unique value in Google Apps Script. Found this useful for random strings to use as Meeting IDs for example.

Source: The Gift of Script: Generate a quick unique(ish) value