Tuesday 29 June 2021

Bulk create Sheets from a Google Sheet

The following Google Apps Script is designed to bulk create Sheets from rows of data within a Google Sheet and to include some of that data within the new file in specific cells. It also creates a link to the new Google Sheet back in the original file on the relevant row.

For those wanting to bulk create Google Docs from a Google Sheet please see this blog post.

Bulk create Google Sheets from a Sheet of data by looping through each row.
Screenshot of Google Sheets data

Tuesday 22 June 2021

Bulk create Shared drives with permissions

The following Google Apps Script is designed to bulk create Google Shared drives all from data in a Google Sheet. It has been packaged into a downloadable tool that you can easily use.

  • 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: example1@example.com, example2@example.com, example3@example.com.
  • 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.
Bulk create Shared drives from a Google Sheet
Bulk create Shared drives from a Google Sheet

Tuesday 15 June 2021

Create a Shared drive

The following Google Apps Script is designed to simply create a Shared drive in Google. It does not add permissions at this stage.

 

Enable Drive API Service

Make sure you have followed the instructions here to enable the Drive API Service.


The Code

First we create a random request ID that uniquely identifies your request for the creation of a Shared drive:

 var requestID = Utilities.getUuid();

Next we provide a name for the Shared drive and format it so the Drive API can read it:

var name = {
  name: 'Shared Drive from Apps Script2'
};

Tuesday 8 June 2021

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 / End date values in a Google Sheet

Tuesday 1 June 2021

Set permissions on a Shared drive

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 permsisions.

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.


Enable Drive API Service

Make sure you have followed the instructions here to enable the Drive API Service.

 

The Code

Below are some comments about snippets of the code to better understand what is happening.

We need to create a JavaScript Object that contains the relevant Shared drive permissions and email addresses as arrays. There are some blank values in this example to show that not every type of role needs something in it:

var roles = {
    organizer: ["
example1@example.com"], // Manager
    fileOrganizer: ["example2@example.com"], // Content Manager
    writer: ["example3@example.com", "example4@example.com"], // Contributor
    reader: [ ] // Viewer
};