Google Apps Script – Why isn’t my add-on showing up in the add-on menu when I test it? (Updated Feb 2022)

Google Apps Script – AuthMode

I mean, when I run it normally, it works just fine!

This is an interesting problem I came across recently when reviewing one of my Google add-ons.

The Problem

The issue was that when I ran my Google Apps Script add-on code normally – in my case, connected to a Google Sheet – the add-on would appear just fine in my add-on menu. However, when I tested the script as an add-on ( run >>> Test as add-on…), as installed for current user but not enabled, my app would not appear in the add-on menu.

If I were to publish this app in this condition (and I may have…eep!), the user would be able to see my add-on in the add-on menu but not be able to access the link to run the app’s function without going into Add-ons >>> Manage add-ons… then click on Manage >>> Use this add-on. The user would have to do this each time they want to apply my add-on to a new Google doc for the first time. Not a good user experience.

The reason is that the first time the app is run in a new document, the Authorization Mode is set to none:


When the user opens the document for the first time, the onOpen(e) trigger function is loaded along with any global variables that are in the script.

This is what Google Apps Script has to say about this:

Google Apps Script onOpen AuthMode None
Source: Add-on Authorization.

So the problem was that one of my Global Variables did not abide by the scope of AuthMode.NONE.

How about we look at some example code to see how to identify the problem and work towards a solution.

The Example

In this example,  I have created a simple Google Sheets Add-on that displays (alert) the correct answer to a question I pose in Google Sheets.  This is what it is supposed to do. And it does if you are running it normally.

(Note: add-ons is now labelled Extensions)

Run Add-on in Google sheets GAS

Google Sheets Alert

When I first created the code and ran it for the first time, I went through all the obligatory authorization requests and the big scary warnings that you should be used to by now when you create and run a script for the first time.

So when I open the Google Sheet attached to my script normally its Authorization mode is AuthMode.LIMITED. This means that some of my cheeky global variables that request access to my data are available to me without invoking an error or script failure warning.

However, when I test the code and run it as an Add-on that is installed, but not enabled, then those cheeky global variables get a hard no from Google Apps Script.

Let’s take a look at the ‘bad’ code and run through identifying the offending Global Variable.

The Bad Code

Okay, time to test this code as an add-on how the user will see it for the first time, installed, but not enabled (AuthMode.NONE).

Test Add-on Installed Not Enagled GAS

When my Google Sheet loads and I go to select the add-on, it isn’t there.

Missing Add-on Google Apps Script

On the Sheet page, hitting F12 for Dev Tools and navigating to the console, I can see the error:

Google Apps Script: You do not have permission to perform that action

Cool. Thanks, Google. I will go back to my script and check our my Google Apps Script and click View >>> Execution transcript.

This is what comes up:

[19-02-21 22:01:47:208 PST] Execution failed: You do not have permission to perform that action. (line 11, file “Code”) [0 seconds total runtime]

Noice! At least I know where the error occurred. It looks like I can’t call SpreadsheetApp.getActiveSpreadsheet() as a Global when the add-on is installed but not enabled.  Fair Enough.

var ss = SpreadsheetApp.getActiveSpreadsheet(); -Line 11

Looking at the Google Apps Script Docs on Add-ons I can now see that, in AuthMode.NONE, I don’t have permission to access the document.

However, it does say I have access to create a menu item so my onOpen function should be fine.

authmode none rules GAS add-on
Source: Add-on Authorization

The Solution

It looks like we need to do one of two things:

  1. Move the offending global variable out of the global variables and into the runAlert_()function.
  2. Turn the SpreadsheetApp.getActiveSpreadsheet() into its own function so that I can continue to use it as a global ‘variable’ should I add to this project with other functions that may call on it.
Hire me for our next Google Workspace project.

The Code – Local Variable Solution

This will handle the error and allow the add-on to run successfully creating the menu item in preparation to run the add-on.  However, it is not particularly efficient if I want to use that SpreadsheetApp.getActiveSpreadsheet() a lot more in other functions down the track.

Create and Publish Google Workspace Add-ons with Apps Script Course 300px

The Code – Global-ish as a Function Solution

Here, we have changed our ss and ui (ui is probably not necessary) to functions. We will use them the same way, but as a function, when the document is loaded, it won’t initialise the SpreadsheetApp in both these cases. This will only occur when they are called in the functions.

Conclusion…read the docs. Do as I say, not as I do and all that. Jeez!

Although I had gone through the docs at the time, creating an add-on for the first, or even the second time, can be a pretty convoluted task to ensure that you meet the standards necessary for scopes, authorization and publishing standards.

I hope that if you have come across this problem in your own Google Add-on development and stumbled upon this post, that this has been of some benefit to you.

Here is a link to the Google Sheet. Make a copy and try out the code!

Why Add-on Menu No Loady Loady?

Create and Publish a Google Workspace Add-on with Apps Script Course

Got a more specific problem you need help with, but don’t have the time to develop the skills? Make an enquiry on my ‘Hire me!’ page. I occasionally pick up projects. If I'm unable to right now, I can still help you find a great trusted freelancer.

5 thoughts on “Google Apps Script – Why isn’t my add-on showing up in the add-on menu when I test it? (Updated Feb 2022)”

  1. Hey this was super super valuble. I was struggling to see why my add-on’s menu (GanttSheet) was not showing up when I would install from the store but local dev was working fine! Wish I came across your solution before I wasted 2 weeks 🙂

    1. Thanks for the kind words. I’ve definitely been there. 😆

  2. Thanks! I have an add-on with over 65k users and was having like 86k errors a day (!) that I never understood until now. I also had a global (or was trying to access the document in onOpen()). It wasn’t stopping my add-on from working (that I know of), but I learned something!

    So, I’m still trying to understand the circumstance where an add-on is installed but NOT enabled (that is, the state where my add-on was getting the error so many times a day). I think I understand that after adding a published add-on, any new document doesn’t have it enabled. But I’m not sure how it gets enabled? Does “enabling” happen when the user invokes the add-on for the first time? I’m using a Forms add-on.

  3. Do you distribute add-ons with a bound THING (spreadsheet, slide, doc)? How does the user ‘apply my add-on to a new Google’ THING? The examples I have seen distribute a bound THING and say keep this as a template and make a copy every time you want to use it. Can a THING have multiple add-ons? Thank you very much for your write-ups. I have tried and then played with many of them for practice.

    1. Hi L.Klein,

      Thanks for the kind words, but more importantly, it is great to hear you tweaking the examples for further practice.

      Add-ons come in 2 flavours:
      – Editor add-ons: These are bound to Google Sheets, Slides, Forms and Docs
      – Google Workspace add-ons: These are relatively new. They can be used in multiple Google Workspace platforms. You will have probably noticed them in the thin sidebar on the right of Gmail or Calendar, but they are also available in other Google Workspace products.

      The add-ons functionality depends on what they are trying to achieve. Probably the best way to understand how they operate is to install a few that interest you and then see how they work. After that go ahead and create one to understand the workflow, this is what I did by creating two very simple add-ons, Spacer and Sections to Sheets.


Leave a Reply

%d bloggers like this: