Gists
This is a sample script for downloading a file using a button of dialog box on Google Docs (Spreadsheet, Document and Slides).
Please use this sample script at script editor on Google Docs (Spreadsheet, Document and Slides). And please set file ID in the script.
FLow : The flow of this sample script is as follows.
Run dialog(). Open a dialog. When users click a download button, retrieve file ID at GAS side.
Gists
Introduction Recently, I have introduced a GAS library and a CLI tool for rearranging files in GAS project. Those are RearrangeScripts and ggsrun. Because today, I found a new way for rearranging files, I would like to introduce it although there is a restriction.
By the recent Google-update, users become able to create folders in GAS project. The new way uses this. At first, please see the demonstration GIF animation.
Gists
This sample script is for retrieving an instance of user-interface environment for Spreadsheet, Document and Slides. When I create applications which use user interface (for example, sidebar, dialog and so on), the user interface can be used for Spreadsheet, Document and Slides. If the application doesn’t use the methods depend on Spreadsheet, Document and Slides, this script can give 3 choices to users.
function getUi() { var ui; try { ui = SpreadsheetApp.
Gists
This is a sample script for combining and mixing 2 objects. Each object is an array which included a dictionary type. When the key of the dictionary object is the same, the values are mixed.
This can be also used for Google Apps Script.
Input var obj1 = [
{"key1": ["value1a1", "value1a2"]},
{"key1": ["value1aa1", "value1aa2"]},
{"key2": ["value2a1", "value2a2"]},
{"key3": ["value3a1", "value3a2"]},
];
var obj2 = [
{"key1": ["value1b1", "value1b2"]},
{"key3": ["value3b1", "value3b2"]},
{"key3": ["value3bb1", "value3bb2"]},
{"key4": ["value4b1", "value4b2"]},
]; Output [
{"key1": ["value1a1", "value1a2", "value1b1", "value1b2", "value1aa1", "value1aa2"]},
{"key2": ["value2a1", "value2a2"]},
{"key3": ["value3a1", "value3a2", "value3b1", "value3b2", "value3bb1", "value3bb2"]},
{"key4": ["value4b1", "value4b2"]}
] Sample script : Javascript : function mixture(obj1, obj2) { Array.
Gists
This sample script is for adding object to object by javascript.
Script : var obj = { key1: "value1", key2: "value2", key3: "value3" }; var obj1 = { key4: "value4", key5: "value5", key6: "value6" }; Object.assign(obj, obj1); console.log(obj); Result : { key1: 'value1', key2: 'value2', key3: 'value3', key4: 'value4', key5: 'value5', key6: 'value6' } jsfiddle demo
Reference : Object.