0

I have tried to create my first google docs add-on.

When I had run the script within a google doc, it worked just fine. However, when I am publishing the add-on and then installed it, it does not work. The error message is :

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

I have determined that the line of code which causes the issue is the last one here:

  var currentDocumentName = DocumentApp.getActiveDocument().getName();
  var currentDocumentID = DocumentApp.getActiveDocument().getId();
  var currentfile = DriveApp.getFileById(currentDocumentID);

So it would appear that using the DriveApp cannot run for some reason.

I know this is the line with error for two reasons. The error message in the google console log says it is this line number. Also, when I put in some logging messages, the messages end where this line is executed. I have given the Google drive API permission in the project.

Does anyone know why this error could occur?

How can I get this to work?

NewLomter
  • 95
  • 1
  • 7
Johno
  • 1

1 Answers1

0

This seems to be a bug. You can click on the star next to the issue number to receive updates and to give more priority to the bug.

As a workaround, try with the Drive API instead (which is different from DriveApp):

var file = Drive.Files.get("fileId");

Jescanellas
  • 2,555
  • 2
  • 9
  • 20
  • may be due to this ? https://developers.google.com/gsuite/add-ons/guides/editor-best-practices#_avoid_relying_too_much_on_libraries – Julien Maret Jul 01 '20 at 14:31
  • It does seem like the bug you mentioned sounds very much like what is happening. I have starred it. One thing I have noted also, is that I removed the add-on from my organisations library. I then tried the code again within the document and it did not work still. So it may relate to the script being converted into a Standard Cloud Platform project? – Johno Jul 03 '20 at 03:23
  • Yes, it could be related. To confirm it, try the same code with a different project, without publishing it as an addon. – Jescanellas Jul 03 '20 at 10:48