google-apps-scriptlibraries

How can I share my code with "Manage Library"?


I just see the new "Manage Library" to share our code. I get how to share a library and how to include a specific version in another script but I don't get how to call a function from the library.

In my library I have simply function

function test() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  ss.toast("this is a test");
}

I open another spreadsheet and include the specific version of my library and I simply write

function onOpen() {
  test();
}

Sadly it doesn't run ...

Can you help me ?


Solution

  • 1) In your "library project" you should save as a version (File > Manage versions)

    2) In your "live project" you should add this library (Resources > Manage Libraries). Then add projectID hash and important is Identifier. (e.g. mylibrary). This is class, how to call method in your code

    mylibrary.test();