July 26, 2018 Updated. Result of reduce was added.
This is a simple sample script for uploading a file using the file input tag of HTML. As the important point, the file is sent as the byte array for using Google Apps Script. By this, at Google Apps Script side, the byte array can be converted to a blob using a simple script.
<input id="file" type="file" onchange="saveFile(this)" />
<script>
function saveFile(f) {| // Load JS from HTML file | |
| eval(HtmlService.createTemplateFromFile("<SCRIPT>").getRawContent()) | |
| // Load JS from URL | |
| eval(UrlFetchApp.fetch("<SCRIPT>").getContentText()) | |
| // Load JS from Google Drive | |
| eval(DriveApp.getFileById("<SCRIPT>").getBlob().getDataAsString()) | |
| // Load JS from URL into global namespace |
| // Put the ID of the folder you want to process | |
| // https://drive.google.com/drive/folders/abcdefgh | |
| const id = "abcdefgh"; | |
| // we will store file names in this dictionary. | |
| // using Set could be more efficient to check if it contains file (time complexity: O(1)) | |
| // App Script does not support Set | |
| const allFiles = []; | |
| // Keep deleted file URLs and report in the end |
This is a report for the documentation comments for the functions of Google Apps Script.
When the documentation comments for functions of Google Apps Script are considered, you will think JsDoc. At Google Apps Script, a part of JsDoc can be used. But, in this report, I would like to introduce the documentation comments including JsDoc.
| /** | |
| * ------------------------------------------ | |
| * MD5 function for GAS(GoogleAppsScript) | |
| * | |
| * You can get a MD5 hash value and even a 4digit short Hash value of a string. | |
| * ------------------------------------------ | |
| * Usage1: | |
| * `=MD5("YourStringToHash")` | |
| * or | |
| * `=MD5( A1 )` |
| /** | |
| * --- UrlFetchApp WITH retries --- | |
| * | |
| * Don't let your script fail easily because of bad API uptime. | |
| * | |
| * Calls provided HTTP requests batch and retries in case of errors. This function has the same | |
| * params and return value as URLFetchApp.fetchAll(). | |
| * https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app#fetchurl-params | |
| * | |
| * @param {Array<object>} requests - Array of request param objects |
This is a sample script for creating a shortcut on Google Drive using Google Apps Script.
Before you run the script, please enable Drive API at Advanced Google services.
function createShortcut(targetId, name, folderId) {A new library, MimeTypeApp, simplifies using Gmail messages and attachments with the Gemini API for tasks like text analysis. It converts unsupported formats for seamless integration with Google Apps Script and Gemini.
Now, Google Docs and Google Sheets can insert smart chips. Smart chips are very useful for easily inserting information like users, maps, files, and so on. However, unfortunately, at the current stage, smart chips cannot be directly managed using Google Apps Script. Specifically, the information within smart chips cannot be directly retrieved by Google Apps Script. Although I believe this will be resolved in a future update, there might be cases where you want to retrieve information from smart chips using Google Apps Script. This report introduces a workaround for achieving this.
The flow of workaround in this report is as follows.
