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?