Search code examples
google-apps-scriptgoogle-sheetsgoogle-sheets-apigoogle-workspace

SpreadsheetApp.getActive() is working on one Google Workspace Domain but not in other domain


We are working on a Google Sheet add-on to manipulate Google Sheets. According to Google documentation, it is recommended to develop add-ons using standalone scripts. We also followed a sample script to create an add-on.

Our created add-on uses SpreadsheetApp.getActive() to access opened spreadsheet. This line of code is working perfectly on our Google Workspace Domain and on our personal Gmail account (.gmail.com).

Now we are trying to replicate the same project on a different domain, above mentioned code return null. This showing the behaviors of the stand-alone app script.

My question is do we need to enable any admin setting on G-Suit Account, to let the addon access the spreadsheet?


Solution

  • This appears to be a bug!

    There is already a report on Google's Issue Tracker which detail the same kind of behaviour:

    Google does seem to know about this issue but if it's causing problems you can indicate this by hitting the ☆ next to the issue number in the top left on the aforementioned page which lets Google know more people are encountering this and so it is more likely to be seen to faster.

    Workaround:

    For now at least it appears that using a broader Spreadsheet scope than spreadsheets.currentonly can get around this, so if this is a possible workaround then this may fix the issue in the mean time.

    Additionally, as per the aforelined issue report, this appears to only affect domains that are on the Scheduled Release track rather than Rapid Release domains. You can review how to change these settings for your domain here (Must be a domain admin to do this)