Home > other >  Google File Picker Dialog no iframe
Google File Picker Dialog no iframe

Time:10-16

I'm trying to set up a file picker in my Google Apps Script for uploading reports. I've gotten it running using the tutorial provided by Google enter image description here

CodePudding user response:

Publish your own custom dialog as a WebApp

Since your implementation is an Add-on, you can open the WebApp-dialog by clicking on a button from the Add-on sidebar.

Sample:

 <button id="portal" onclick="window.open('https://script.google.com/macros/s/XXX/exec', '_blank')" id="myButton" >open Picker in a custom WebApp dialog</button>

Whereby https://script.google.com/macros/s/XXX/exec is the deployment URL of your WebApp.

For the WebApp itself, replace

function showPicker() {
  var html = HtmlService.createHtmlOutputFromFile('PickerHTML2.html')
      .setWidth(600)
      .setHeight(425)
      .setSandboxMode(HtmlService.SandboxMode.IFRAME);
  SpreadsheetApp.getUi().showModalDialog(html, 'Select a file');
}

through

function doGet() {
   var html = HtmlService.createTemplateFromFile('PickerHTML2.html')
   return html.evaluate().setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
}

and deploy the code as a WebApp.

  • Related