0

Hi following Tanaike's answer here, I was able to successfully implement a form into a pop-up window in my google sheet, however when another user (that I've set as editor attempt to open this pop up I get this error message:

"You do not have access to perform that action. Please ask the owner of this item to grant access to you."

It is not clear how I can grant further access to this second user as he's already set as editor.

Here is the script I trigger:

function launchForm() {
  var formTitle = '';
  var formID = '14uZANF9q3FKQvfLD1Qx-enYdeQ_pxzORTeHwSSKtHOk';
  var form = FormApp.openById(formID);
  var formUrl = form.getPublishedUrl();
  var htmlApp = HtmlService
  .createHtmlOutput('<script>location.href = "' + formUrl + '"</script>')
  .setSandboxMode(HtmlService.SandboxMode.IFRAME)
  .setTitle(formTitle)
  .setWidth(900) 
  .setHeight(750);
  SpreadsheetApp.getActiveSpreadsheet().show(htmlApp);
}


function onOpen() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet();
  var entries = [{
    name : "Launch Form",
    functionName : "launchForm"
  }];
  sheet.addMenu("Custom Menu", entries);
};
alice-let
  • 37
  • 4

1 Answers1

0

I've actually found an alternative which solved my problem. In case anyone face the same issue, here is what I did:

function myForm() {
  var html = HtmlService.createHtmlOutputFromFile('myForm')
  .setSandboxMode(HtmlService.SandboxMode.IFRAME);
  SpreadsheetApp.getUi()
  .showModalDialog(html, 'Hello');
}

and created a HTML file:

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
<iframe src="..." width="500" height="500" frameborder="0" marginheight="0" marginwidth="0">Loading...</iframe>  </body>
</html>

Note: you can find the iframe tag when you go to edit your form in Google form > and click Send > click tab Embed HTML

alice-let
  • 37
  • 4
  • 2
    The reason your co worker couldn't run your script is because they did not have viewer access to your form. they need that in order to open the application with `FormApp.openById()`. – tehhowch Mar 20 '18 at 13:25