Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
330 views
in Technique[技术] by (71.8m points)

Google Sheets OnEdit() - You do not have permission to call a service

Since the beginning of this month this code has not more been working

function onEdit(e){    
              var html = HtmlService.createTemplateFromFile( 'MyHtmlFile' )
              .evaluate()
              .setWidth( 800 )
              .setHeight( 400 );
              SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
              .showModalDialog( html, 'My page title' ); 
}

When I edit a Spreadsheet's cell NO pop up is shown but I got this error in the console:

Google Apps Script: You do not have permission to call showModalDialog

question from:https://stackoverflow.com/questions/65660534/give-permission-to-google-docs-from-spreadsheet

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The onEdit() will have to be an Installable Trigger because it is using a service that requires authorization.

note: rename onEdit() when using it as an installable trigger to avoid possible issues

Like simple triggers, installable triggers let Apps Script run a function automatically when a certain event, such as opening a document, occurs. Installable triggers, however, offer more flexibility than simple triggers: they can call services that require authorization, ...

Managing triggers manually:

To manually create an installable trigger through a dialog in the script editor, follow these steps:

  1. From the script editor, choose Edit > Current project's triggers.
  2. Click the link that says: No triggers set up. Click here to add one now.
  3. Under Run, select the name of function you want to trigger.
  4. Under Events, select either Time-driven or the Google App that the script is bound to (for example, From spreadsheet).
  5. Select and configure the type of trigger you want to create (for example, an Hour timer that runs Every hour or an On open trigger).
  6. Optionally, click Notifications to configure how and when you will be contacted by email if your triggered function fails.
  7. Click Save.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...