Re: [Apps-Script] onOpen() function not working

1,536 views
Skip to first unread message

gk adanama

unread,
May 24, 2022, 2:48:19 AM5/24/22
to google-apps-sc...@googlegroups.com
im sorry, im not playing around on google script anymore, and im forgot about everything,
try to search on youtube.
I hope you found the answer.

On Tue, May 24, 2022 at 1:25 PM Sushen Ranjan Das <sushenr...@gmail.com> wrote:
Hii, My Name is Sushen and I am new in Google App Script development. I just trying to create a script where when i open a spreadsheet it loads a form in that sheet. 
My code is looks :- 

function onOpen(){
  const sidebar_html = HtmlService.createTemplateFromFile("Admission_frm");
  const htmloutput = sidebar_html.evaluate();
  const ui = SpreadsheetApp.getUi();
  ui.showSidebar(htmloutput);
}

But onOpen() function not running.

What to do Please help

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/62b29978-aaa1-44a6-a023-070c20189b64n%40googlegroups.com.

Andrew Roberts

unread,
May 24, 2022, 4:01:29 AM5/24/22
to google-apps-sc...@googlegroups.com
Look at the error reporting. The "simple" onOpen trigger doesn't have permisiion to open the sidebar.

Irfan Khan

unread,
May 24, 2022, 5:02:29 AM5/24/22
to Google Apps Script Community
Simple Trigger don't have required scope to open sidebar/modal, i would recommend you to add menu item through onOpen and link sidebar opening functionality with those buttons.

Andrew Apell

unread,
Jun 28, 2022, 5:41:49 AM6/28/22
to Google Apps Script Community
I have a function running under onOpen(); it is supposed to launch a modal window under certain circumstances.
I have tested it 3 times and the modal window is being displayed as expected.

Secrétariat

unread,
Jun 28, 2022, 7:14:01 AM6/28/22
to google-apps-sc...@googlegroups.com
Like this the Sidebar is open when the doc is opened

Add trigger at the Opening "openDialog2"


function onOpen() {
// Add a menu with some items, some separators, and a sub-menu.

DocumentApp.getUi().createMenu('D')
DocumentApp.getUi().createMenu('-> Analyses ')
.addItem('NEWS --> Traceur Analyses Biologie ','traceur')
.addItem('Sidebar --> Traceur Analyses ','openDialog2') //not necessary
.addToUi();
openDialog2() //Open Sidebar
}


function openDialog2() {
var html = HtmlService.createHtmlOutputFromFile('Page').setSandboxMode(HtmlService.SandboxMode.IFRAME)
.setWidth(150)
// .setHeight(300)
.setTitle(" Title ");
DocumentApp.getUi().showSidebar(html);

}
Capture d’écran 2022-06-28 à 13.11.12.png
Reply all
Reply to author
Forward
0 new messages