2
votes

I converted my sheets from the old to the new sheets as the code started creating sheets in the new version which was causing it to fail. After converting, I am now getting another error which I cannot find a solution for.

The error seems to be when using UiApp which calls a server handler and there is a library attached to the project. The error occurs even when there is no code in the library. The error occurring is:

Server Error: We're sorry, a server error occurred. Please wait a bit and try again.

Steps to reproduce

(1). Create 2 new sheets, use one as the library and one as the test sheet

(2). In the library, add a new version to the project then add the project as a library in the test sheet. There should be no code in the library (doesn't really matter either way).

(3). In the test sheet, add the following code:

function test() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var app = UiApp.createApplication();

  // create a button and handler
  var buttonHandler = app.createServerHandler("buttonTest");
  var button = app.createButton("Button Test");
  button.addClickHandler(buttonHandler)

  app.add(button)
  ss.show(app); // Display the app
}
function buttonTest(e) {
  // nothing here is executed
}

(4). Run the test code

The following error is displayed: Server Error: We're sorry, a server error occurred. Please wait a bit and try again.

If the library is removed then it will run as expected

1
Well this pretty much makes libraries useless doesn't it. Please ping me if you get an answer to this.RubberDuck

1 Answers

0
votes

The UiApp is deprecated. That would be creating the server error. Sometimes the UiApp functions still work (like the chart service) but the output crashes. The googlescript library functionality should still work.

https://developers.google.com/apps-script/reference/ui/ui-app?hl=en

The html service should be a replacement for the UiApp but unfortunately it does not cover all the same functionality.

https://developers.google.com/apps-script/guides/html/