tanaike - Google Apps Script, Gemini API, and Developer Tips

The Thinker

Managing History of Google Apps Script

Gists

Abstract

This report introduces the method for managing the histories of the Google Apps Script project.

Description

On August 23, 2023, the project history has been implemented in the new IDE of Google Apps Script. Ref and Ref In the current stage, the users can see the history of the previously deployed script version. This is a very important implementation for a lot of developers.

Here, I remember the classic IDE. In the case of the classic IDE, the users had been able to see the previously saved script version regardless of the deployment and just the save of the script. This is not implemented in the new IDE. I would like to expect that this will be implemented in the future update.

GAS Library - ScriptHistoryApp

Overview

This is a Google Apps Script library for managing the histories of the Google Apps Script project.

Description

On August 23, 2023, the project history has been implemented in the new IDE of Google Apps Script. Ref and Ref In the current stage, the users can see the history of the previously deployed script version. This is a very important implementation for a lot of developers.

Here, I remember the classic IDE. In the case of the classic IDE, the users had been able to see the previously saved script version regardless of the deployment and just the save of the script. This is not implemented in the new IDE. I would like to expect that this will be implemented in the future update.

Taking Advantage of Auto-completion of Script Editor for Google Apps Script

Gists

Introduction

This is a report for taking advantage of the auto-completion of the script editor for Google Apps Script.

In the current stage, the auto-completion is implemented in the script editor of Google Apps Script. This auto-completion can be used for not only the built-in classes and methods but also the methods for Javascript. This helps develop scripts and applications very much. In the case of the built-in classes and methods and the methods for Javascript, you can see the detailed specifications of the documents like the official documents and developer.mozilla.org.

Copy Date Object between Google Spreadsheets with Different Timezone using Google Apps Script

Gists

This is a sample script for copying the date object between Google Spreadsheets with the different time zones using Google Apps Script.

One day, you might have a situation in which it is required to copy the date object between Google Spreadsheets with the different time zones using Google Apps Script. In this post, I would like to introduce the sample scripts for achieving this.

Sample situation

Here, the sample situation is declared. In order to test the below scripts, please create 2 Google Spreadsheets.

Focusing Selected Cell to Top Left on Google Spreadsheet using Google Apps Script

Gists

This is a sample script for moving the selected cell to the top left on Google Spreadsheet to focus it using Google Apps Script.

One day, there might be a case where you are required to focus the specific cell on Google Spreadsheet to help edit cells. In this post, I would like to introduce a sample script for achieving this.

Sample script

Please copy and paste the following script to the script editor of Google Spreadsheet, and save the script.

Report: Values to transfer between Javascript and Google Apps Script with google.script.run

Gists

At the Google Apps Script project, the values can be transferred from HTML to Google Apps Script using google.script.run with Javascript. In this case, unfortunately, the values of all types cannot be transferred. In the official document, it says as follows. Ref

Most types are legal, but not Date, Function, or DOM element besides form; see description

Legal parameters are JavaScript primitives like a Number, Boolean, String, or null, as well as JavaScript objects and arrays that are composed of primitives, objects, and arrays. A form element within the page is also legal as a parameter, but it must be the function’s only parameter. Requests fail if you attempt to pass a Date, Function, DOM element besides a form, or other prohibited type, including prohibited types inside objects or arrays. Objects that create circular references will also fail, and undefined fields within arrays become null. Note that an object passed to the server becomes a copy of the original. If a server function receives an object and changes its properties, the properties on the client are not affected.

Add Header and Footer to Exported PDF from Google Spreadsheet using Google Apps Script

Gists

This is a sample script for adding header and footer to PDF using Google Apps Script.

In the current stage, when Google Spreadsheet is manually exported as a PDF file at “Print settings” on the UI of Spreadsheet, the custom header and footer can be added as shown in the following image.

But, unfortunately, in the current stage, this cannot be directly achieved by Google Apps Script. So, I created this sample script. This sample script uses pdf-lib of Javasscript library.