We're sorry, a server error occurred while reading from storage. Error code NOT_FOUND
Asked Answered
M

5

18

I'm facing this issue while I'm running the script. one day before if was working fine for me. I did clear all the cache of chrome browser and I tried another laptop also but the issue is as it is. please help me to resolve the issue.

The code I'm running is:

function onOpen(e) {
  var menu = SpreadsheetApp.getUi().createMenu('Reporting Tools');
  menu.addItem('Create Unit Scorecards', 'HSIPScorecard2021CountryScripts.createInputSheets');
  menu.addItem('Notify Unit H&S Heads', 'HSIPScorecard2021CountryScripts.sendNotifications');
  menu.addItem('Consolidate Unit Data', 'HSIPScorecard2021CountryScripts.Consolidate');
  menu.addToUi();
}
Monkey answered 7/1, 2021 at 11:56 Comment(3)
is this intended to be an addon?Thumbstall
Is this HSIPScorecard2021CountryScripts the name of your library and has it been installed properly?Matinee
Related bug report on the Google Apps Script issue tracker: Using a lib that has view permissions gives "a server error occurred while reading from storage. Error code NOT_FOUND."Propound
D
28

I just ran into the same problem last week. After wasting a few day's time, I found it was caused by a reference to a library using development mode. Change it to a deployment version solved that.

Diversion answered 18/1, 2021 at 10:55 Comment(2)
For future viewers: This appears to still be a solution as of August 2021. Certainly, I had the same issue described by the OP and this answer resolved it directly.Wiper
Update April 2023; you can also overcome this by using an installed onOpen() trigger in the library.Mineralize
M
1

Assuming that the name of the library is correct you can write that like this:

function onOpen(e) {
      SpreadsheetApp.getUi().createMenu('Reporting Tools')
      .addItem('Create Unit Scorecards', 'HSIPScorecard2021CountryScripts.createInputSheets');
      .addItem('Notify Unit H&S Heads', 'HSIPScorecard2021CountryScripts.sendNotifications');
      .addItem('Consolidate Unit Data', 'HSIPScorecard2021CountryScripts.Consolidate');
      .addToUi();
    }
Matinee answered 7/1, 2021 at 19:19 Comment(0)
L
1

There are two things that need to be checked in order to fix this issue.

  1. The Library reference should link to the Deployment Version and not to the Development Mode.
  2. The Library file should not be restricted in case you are sharing the copy of the original file with somebody else.
Lordinwaiting answered 29/6, 2022 at 9:54 Comment(1)
Does it matter if they are a viewer or an editor on the file?Uplift
C
0

I had the same error... It appeared that the library (HSIPScorecard2021CountryScripts in your case) had a reference to another library (BasicTools). From the account that owned both, it worked. However, from any other account, that error appeared. Even if Edit permission was given.

The solution was to move the functions from BasicTools to HSIPScorecard2021CountryScripts (and fix the functions calls).

So, in short, one more solution to try is to make sure the library you are using doesn't use any other libraries.

Canst answered 14/12, 2022 at 20:16 Comment(0)
M
0

Using an installable trigger in the parent library (instead of onOpen() in the dependent script) also fixes this issue.

ScriptApp.newTrigger('exported.createDefaultMenuAndAddToUI')
  .forSpreadsheet(SpreadsheetApp.getActive())
  .onOpen()
  .create(); 

It will give you a new problem in that the menu item actions are outside of the dependent library scope. I manage referencing things that need to be accessed by both the library and its dependent scripts like this:

function getExports () {
  return {  
    /* TRIGGERS */
    hourlyCronTask, 
    createDefaultMenuAndAddToUI,
    /* MENU ITEMS */
    actionInitialHelp,
    ...
  };
}

const exported = getExports();

Then in dependent script Code.js

const exported = MyParentLibrary.getExports();

These need to be defined in a hoistable function rather than a constant since only these are exposed to dependent scripts.

Mineralize answered 11/4, 2023 at 20:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.