J-J
J-J

Reputation: 5871

Google App Script showing a prompt in doc not working with out spreadsheet permission

I am trying to show a message box in Google Doc using App Script.

Browser.msgBox("Hi There");

When I run this I am getting the below error.

You do not have permission to call Browser.msgBox. Required permissions: (https://www.googleapis.com/auth/spreadsheets.currentonly || https://www.googleapis.com/auth/spreadsheets) (line 2, file "restore")

The following are the manifest entries present in my doc project.

 "oauthScopes" : [
    "https://www.googleapis.com/auth/activity",
    "https://www.googleapis.com/auth/script.container.ui",
    "https://www.googleapis.com/auth/userinfo.email",
    "https://www.googleapis.com/auth/documents.currentonly",
    "https://www.googleapis.com/auth/drive",
    "https://www.googleapis.com/auth/drive.appdata",
    "https://www.googleapis.com/auth/gmail.compose",
    "https://www.googleapis.com/auth/script.scriptapp"
  ] 

Can anyone tell me how to make Browser.msgBox("Hi There") work without adding sheet permissions in manifest?

Upvotes: 3

Views: 351

Answers (1)

Tanaike
Tanaike

Reputation: 201378

  • You want to open a dialog on Google Document.

If my understanding is correct, how about this workaround? Unfortunately, Class Browser can be used for Spreadsheet. The official document says as follows.

This class provides access to dialog boxes specific to Google Sheets.

The methods in this class are only available for use in the context of a Google Spreadsheet. Please use G Suite dialogs instead.

So how about using Class Ui as follows?

DocumentApp.getUi().alert("Hi There");
  • In this case, no scopes are used.

References:

If I misunderstood your question, I apologize.

Upvotes: 2

Related Questions