Skip to content

Instantly share code, notes, and snippets.

@KenjiOhtsuka
KenjiOhtsuka / copy_files.gs
Last active May 5, 2024 00:25
Google Apps Script to Copy Folder Recursively
/**
This is a code of Google Apps Script for copying google drive folder content to other folder.
## Which situation the code resolve.
Google doesn't allow to move folder content to other folder which is managed by
other organization according to the policy of the GSUITE organization.
And, Google doesn't allow to change the content owner to the user in other
organizations.
@ruzz311
ruzz311 / macros.gs
Created September 6, 2018 18:16
Google Sheets Macro Function - Highlight a max/min values in a column
/** @OnlyCurrentDoc */
function myFunction2() {
var spreadsheet = SpreadsheetApp.getActive();
var conditionalFormatRules = spreadsheet.getActiveSheet().getConditionalFormatRules();
conditionalFormatRules.push(SpreadsheetApp.newConditionalFormatRule()
.setRanges([spreadsheet.getActiveRange()])
.whenFormulaSatisfied('=$H:$H=max(H:H)')
.setBackground('#B7E1CD')
@pbaruns
pbaruns / InsertDateTime
Last active July 31, 2019 06:31
Insert Date Time
/**
* The onOpen function runs automatically when the Google Docs document is
* opened. Use it to add custom menus to Google Docs that allow the user to run
* custom scripts. For more information, please consult the following two
* resources.
*
* Extending Google Docs developer guide:
* https://developers.google.com/apps-script/guides/docs
*
* Document service reference documentation:
@goelp
goelp / gas_qbo_oauth2.js
Last active January 28, 2024 11:36
Google Apps Script OAuth2 script for QuickBooks integration with Google Sheets
var CLIENT_ID = '...'; // Get from Quickbooks Developer Console
var CLIENT_SECRET = '...'; // Get from Quickbooks Developer Console
var BASE_AUTH_URL = 'https://appcenter.intuit.com/connect/oauth2';
var TOKEN_URL = 'https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer';
var API_SCOPE = 'com.intuit.quickbooks.accounting';
var REDIRECT_URI = '...'; // Generate using the logRedirectUri() function mentioned at the end of this script
var RESPONSE_TYPE = 'code';
/**
* Authorizes and makes a request to the Quickbooks API using OAuth 2.
@JEverhart383
JEverhart383 / Code.gs
Created August 10, 2017 19:27
Google Sheets Web App | DaVinci Center ODEO
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var USERS_TABLE = spreadsheet.getSheets()[0];
var IDEAS_TABLE = spreadsheet.getSheets()[1];
var VOTES_TABLE = spreadsheet.getSheets()[2];
function registerUser(user){
var data = getTableData(USERS_TABLE);
@andrewroberts
andrewroberts / convertSpreadsheetToPdf.gs
Last active June 1, 2024 13:50
Convert a multi-sheet Google Spreadsheet into a PDF, with option to email it.
/*
* Save spreadsheet as a PDF
*
* Based on Dr.Queso's answer in http://stackoverflow.com/questions/30367547/convert-all-sheets-to-pdf-with-google-apps-script/30492812#30492812
*
* @param {String} email Where to send the PDF [OPTIONAL]
* @param {String} spreadsheetId Or the active spreadsheet[OPTIONAL]
* @param {String} sheetName The tab to output [OPTIONAL]
* @param {String} PdfName [OPTIONAL]
*/
@JaredLGarcia
JaredLGarcia / Team Drive Migration Google Apps Scripts Tool
Last active May 10, 2023 03:57
Team Drive Migration Google Apps Scripts Tool
//Set of Functions that can be attached to a Google Spreadsheet to facilitate a Google Drive Shared Folder to Team Drive Migration
//Author: Jared Garcia
//Attach to a Spreadsheet with three Sheets
//Link to spreadsheet template: https://docs.google.com/spreadsheets/d/1TPPx1XrEcyXRurZWKpy9Qkm0HSpbkFG3FI8q2jzukuE/edit?usp=sharing
//First Sheet needs to be named "Folder Analysis" and havethe following Data in the first row Folder Name, Folder ID, Owner, Parent Folder Name, Parent Folder ID, Gather Folders [NO/YES], Gather Files [NO/YES],
//Team Drive Duplicate Name,TD Duplicate ID, File Move [NO/YES], File Move Complete
//The Second Sheet should be named "File Analysis" and have the following data File ID, Owner, Folder Parent, Parent ID, Team Drive Move (Y/N)
//Third Sheet is called "Change Owner Commands". This sheet isn't necessary but is handy when you need to change a file/folders owner using Google Apps Manager commands.
//Version. 0.8
//This is not a completed script as of yet. It currently gathers fo
@superstrong
superstrong / google-script-basecrm-api.js
Created November 19, 2016 02:13
Retrieve JSON data from the BaseCRM API and add it to a Google Sheet. This example retrieves all users. Stands on the shoulders of https://gist.github.com/varun-raj/5350595a730a62ca1954
function getBaseUsers() {
var options = {
"contentType" : "application/json",
"headers" : {
"Accept": "application/json",
"Authorization": "Bearer <TOKEN>"
}
}
var response = UrlFetchApp.fetch("https://api.getbase.com/v2/users", options);
var ss = SpreadsheetApp.getActiveSpreadsheet();
@andrewroberts
andrewroberts / TrialBalance.gs
Last active December 17, 2017 15:27
Google Apps Script request to Xero API for trial balance - snippet for Xero Forum question
function getTrialBalancesWithNoDate() {
// .
// .
// .
fetchPublicAppData('Reports/TrialBalance', '', '') // OK
// .
// .
/*
Copyright 2011 Martin Hawksey
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software