Use Google Apps Script libraries

How to create libraries

If you want to use libraries, you have to create at least one library in advance. Please refer the following page to learn how to create them.

Create Google Apps Script libraries

Step 1. Get Project Key

Go to “File” -> “Project properties”.

Copy project key on the info tab.

Step 2. Add a library

Go to “Resources” -> “Libraries…”.

Paste a project key in a text box and click “Add” button.

Completed to add a library.

Step 3. Edit parameters

Select version.

Edit identifier you like. (It allows only alphanumeric and half-width symbols)

Select development mode.

Once the Development mode is on, the followings become true:

(1) Anyone who has editor-level access to the script has the latest changes made to the files in the library project even if it was not saved as a version.
(2) The autocomplete is still generated based on the selected version.
(3) Anyone with only the read-level access to the script still uses the selected version regardless of whether the development mode is on or off.

If you have nothing to edit more, please click “Save” button.

Step 4. Use libraries

Here is a sample to call a message dialog:

/**
 * Original Library
 */
function createMessageDialog(message){
  var app = UiApp.createApplication();  
  app.add(app.createLabel(message));
  return app;
}/**
/**
 * Call Library (identifier: library)
 */
function onOpen() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  ss.show(library.createMessageDialog('Test message'));
}

1 thought on “Use Google Apps Script libraries”

Leave a Comment