The Thinker

Linking Cloud Platform Project to Google Apps Script Project

Gists Introduction At April 8, 2019, the specification of Google Apps Script Project was changed. You can see this at Google Cloud Platform Projects. The official document says as follows. Warning: Starting on or after April 8, 2019, the Google Cloud Platform Console won’t be able to access the default GCP projects created for new Apps Script projects. Older, existing scripts may have default GCP projects that are still accessible, however.

Dynamically Retrieving Keys and Values from Struct Property

Gists This is a sample script for dynamically retrieving the keys and values from struct property using golang. Sample script: Go Playground package main import ( "fmt" "reflect" ) func main() { s := struct { key1 string key2 string key3 string }{"value1", "value2", "value3"} r := reflect.ValueOf(&s).Elem() rt := r.Type() for i := 0; i < rt.NumField(); i++ { field := rt.Field(i) rv := reflect.ValueOf(&s) value := reflect.Indirect(rv).FieldByName(field.Name) fmt.

Sorting for Slice using Golang

Gists This is a sample script for sorting a slice using Golang. Recently, I had a situation for sorting the coordinates of cells of Spreadsheet. As a test case, it thinks of the situation that the randomized cells are sorted. I think that this can be also used for a table except for Spreadsheet. Sample slice: The sample slice is as follows. ar := []struct { row int col int value string }{ {0, 0, "A1"}, {0, 1, "B1"}, {0, 2, "C1"}, {1, 0, "A2"}, {1, 1, "B2"}, {1, 3, "D2"}, {2, 0, "A3"}, {2, 2, "C3"}, } When each element of above slice is put to a Spreadsheet, it becomes as follows.

GAS Library - GetEditType

Overview GetEditType is a GAS library for retrieving the edit types of the OnEdit event trigger of Spreadsheet using Google Apps Script (GAS). Description In the case that the OnEdit event trigger (simple and installable triggers) is used at Spreadsheet, when users manually edited the cell of Spreadsheet, the trigger is fired. At this time, there is the case that I want to know the edit type. For example, I would like to know about the following edit types.

Fixing Value Putting by Custom Function of Spreadsheet using Google Apps Script

Gists This is a sample script for fixing a value putting by a custom function of Spreadsheet using Google Apps Script. When a custom function is used, the value retrieved by the custom function of Spreadsheet is automatically updated by recalculating. So in the case that the value retrieved by the custom function is changed by the time, the value is also changed by automatically updating. In this sample script, I would like to introduce a method for fixing such values.