0

I made a google sheets add on and it worked well. Then I published it privately so that others in my organization can have access to it. However the custom menu that is supposed to be added to the add-on menu does not show up and I only see the default Help item through my add-on menu. When I open logging, it shows that both my onInstall and onOpen failed. I can't see any error messages anywhere though.

This is the code in my script calling the development version of my custom library.

let sheet = SpreadsheetApp.getActiveSheet();

function GetFromPlaylistIdYoutube()
{
  YoutubeLibrary.GetFromPlaylistIdYoutube(sheet);
}

function onInstall(e) {
   onOpen(e);
}

function onOpen(e) {
  var ui = SpreadsheetApp.getUi();
  // Or DocumentApp or FormApp.
  ui.createAddonMenu()
    .addItem("From Playlist ID", "GetFromPlaylistIdYoutube")
    .addToUi();
}

These are the logs that I see when I install and reload my google sheets. enter image description here

Does anyone know why it is failing while it is working just fine when I don't publish it. For reference please note that this add-on script is a standalone script.

Monu Yadav
  • 519
  • 2
  • 17
  • 1. Google Workspace add-ons and Editor add-ons are not the same. 2. Please add more details, i.e. YoutubeLibrary is library? Is it shared with anyone in. your organization? Have you included the required scopes and enabled the required API in you Google Cloud project and on the Google Workspace Marketplace SDK? – Rubén Mar 07 '22 at 05:58
  • @RubénI understand that workspace and editor add-ons are not the same. It's an editor add-on. YoutubeLibrary is a custom library and I think I made it clear when I said that I'm using the development brach of it. The required scopes are enabled in both Google cloud project consent screen and google workspace marketplace SDK. Why would I have to share the code with anyone if I'm looking to publish it as an add-on? – Monu Yadav Mar 07 '22 at 06:07
  • Thanks for your reply. 1. You should share your library otherwise the add-on users can't run the functions that depend on the library 2. You should publish a version of your library to use it on an add-on. – Rubén Mar 07 '22 at 06:11
  • Related: https://stackoverflow.com/q/53459203/1595451 – Rubén Mar 07 '22 at 06:17
  • Thank you for your responses @Rubén. But I don't think it has anything to do with my custom library code. I got rid of it and put a simple Add function in it's place and the onInstall and onOpen triggers still fail to run. I updated my question to reflect that this add-on script is a standalone script. – Monu Yadav Mar 07 '22 at 06:23
  • What's the error? – Cooper Mar 07 '22 at 07:03
  • The last edit still shows the library. Again, published add-ons can't use the head deployment of libraries. If you haven't done yet, deploy your library and set the library reference in your add-on to use a version of your library and share your library to view only for your domain or anyone on the web. If the problems persist, take a look to the Issue Tracker. The last days there are several issues. – Rubén Mar 07 '22 at 07:33
  • Thanks @Rubén. Based on your advice I decided to deploy my library and use its deployed version. Then I got an error "Library with identifier YoutubeLibrary is missing". Found that its already registered in the [issue tracker](https://issuetracker.google.com/issues/179397312) and marked obsolete. Seems like google doesn't want us to use libraries for add-on at all. – Monu Yadav Mar 07 '22 at 08:11
  • If you haven't done yet, create a [mcve] of your library and add the code to question. – Rubén Mar 07 '22 at 15:23
  • Were you able to test it without including the library? It could be that the bug is also causing the triggers to fail. If it does work without it then the bug has a few workarounds such as making the library public, changing to the old runtime (since according to the bug it only happens in the V8 runtime) or including the library code in your project. Google does discourage including libraries in add-ons due to performance issues, as you can see [here](https://developers.google.com/apps-script/guides/libraries). – Daniel Mar 08 '22 at 00:24
  • I was able to make it work without the library. The Library itself had no bug and it was well tested and is in use for months. I copied the code from library to add-on script and it worked perfectly. That just means it's probably a bug in app script. I made multiple deployments to test all edge cases and concluded it had to do with app script and not with my code. I knew of the performance penalty and I was fine with it. – Monu Yadav Mar 08 '22 at 02:39

0 Answers0