google-apps-script Getting started with google-apps-script A deeper look at Google Apps Script

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

Google Apps Script is a JavaScript based platform-as-a-service primarily used to automate and extend Google Apps. Apps Script runs exclusively on Google's infrastructure requiring no server provisioning or configuration. An online IDE serves as the interface to the entire platform connecting all the services that are available to Apps Script. User authentication is baked into the platform via OAuth2 and requires no code or setup by the script author.

Apps Script runs server-side, but can have user interfaces built with Html, CSS, JavaScript, or any other browser supported technologies. Unlike Nodejs, which is event driven, App Scripts runs in a threaded model. All calls to a script generate a unique instance of that script which runs in isolation of all other instances. When an instance of a script finishes execution it is destroyed.

Functions in Apps Script are blocking so callback and async programming patterns are not needed. Locking is used to prevent critical sections of code, such as file IO, from being executed simultaneously by different instances.

In practice writing Apps Scripts are simple. Below is a simple script that creates a new spreadsheet from a template spreadsheet.

// Create a new spreadsheet from a template
function createSpreadsheet(){
   var templateFileId = '1Azcz9GwCeHjGl9TXf4aUh6g20Eqmgd1UMSdNVjzIZPk';
   var sheetName = 'Account Log for:' + new Date();
   SpreadsheetApp.openById(templateFileId).copy(sheetName);   
} 


Got any google-apps-script Question?