Unable to test add-on under 'Installed for current user' config (i.e. AuthMode.NONE)

前端 未结 1 1949
不知归路
不知归路 2021-01-26 15:31

I\'m trying to build my first editor add-on where the same codebase is supposed to work on Docs, Sheets and Slides.

I\'m still in the testing phases and that\'s where I\

相关标签:
1条回答
  • 2021-01-26 16:08

    When a script file is loaded into memory for execution of any function (onOpen or any other function), all global variables are loaded/executed. Your issue stems from attempting to get the active(getActive*()) document under AuthMode.None.

    If you can get to Ui without getting to getActive() that's possible. But you're attempting to access the document inbetween:

    SpreadsheetApp .getActiveSpreadsheet() ? SpreadsheetApp.getUi().

    The bolded part is causing the issue. SpreadsheetApp.getUi() will work fine.

    You can also try try{...}...catch(e){} instead.

    References:

    • Authorization modes - Access to document: No under AuthMode: "NONE" table

    • Related answer - May not work.

    0 讨论(0)
提交回复
热议问题