0

I have been searching high and low and can not find a concrete answer. Some questions say yes others say no. In the case, I have a script I want to run that creates a custom menu/menu item that runs another script. I have this installed as an installable trigger set to run onOpen. This works marvelously for me or anyone else logged into google. Using incognito or not being logged in not so much. I have also attempted doing this via web app publishing using the "execute the app as" "Me" and "who has access to the app" "Anyone, even anonymous". This again works great for me and anyone logged in not so much for incognito or people not logged in. I am pretty much at the end of my rope trying to make heads or tails of this.

/* Global */ var width = 1000; var height = 700; /** * Creates a trigger for when a spreadsheet opens. */ function createSpreadsheetOpenTrigger() { var ss = SpreadsheetApp.getActive(); ScriptApp.newTrigger('onOpen') .forSpreadsheet(ss) .onOpen() .create(); } function onOpen() { SpreadsheetApp.getUi().createMenu('Freight Form').addItem('Freight Form', 'freight').addToUi(); } function freight(){ var hs = HtmlService.createTemplateFromFile('ModalDialog'); hs.width = width; hs.height = height; hs.publishedUrl = SpreadsheetApp.openById("spreadsheetID*").getFormUrl();https://docs.google.com/forms/d/e/spreadsheetID*/viewform?usp=sf_link var userInterface = hs.evaluate() .setWidth(width) .setHeight(height); SpreadsheetApp.getUi().showModalDialog(userInterface, 'Form'); } function getSize(type){ if(type === 'width') return width - 20; if(type === 'height') return height - 20; return 600; } 
7
  • Edit to use proper tags to reach the right audience. Commented Sep 20, 2019 at 7:09
  • See the following links: stackoverflow.com/questions/27173605/… stackoverflow.com/questions/26318755/…, developers.google.com/apps-script/guides/services/authorization Commented Sep 20, 2019 at 13:44
  • @ziganotschka While I have read all of those already I may be ignorant as to their meaning. It sounded to me that if I published the Web App under the ("execute the app as" "Me" and "who has access to the app" "Anyone, even anonymous".) then it should run as me even for anonymous users. Serge insas states that "The installable onEdit will work since it works as you, not the unlogged user. " I have tried both onedit and onopen to no avail. I can post the code if that would help. Commented Sep 20, 2019 at 14:43
  • 1
    Those posts point out that the WebApp will work only frontend for anonymous users. You won't have access to SpreadsheetApp.getUi() - which you need to create a menu. Commented Sep 20, 2019 at 14:56
  • Thank you for the clarification. So it sounds like what I am wanting to do is not doable via google applications. Commented Sep 20, 2019 at 15:20

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.