Running Google Docs Add On Drive permissions

62 views Asked by At

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?

1

There are 1 answers

3
Jescanellas On

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");