Workspace Addon open after closing

104 views
Skip to first unread message

Saurabh Mathur

unread,
Jan 23, 2023, 4:07:45 AM1/23/23
to Google Apps Script Community
Hi,

I am building a workspace addon using the HtmlService.

The code for which is as follows

function showForm() {
var form = HtmlService.createHtmlOutputFromFile('ui');
SpreadsheetApp.getUi().showSidebar(form);
}

function onOpen(e) {
console.log("onOpen", JSON.stringify(e));
showForm();
}

Now, when I open a google sheet, the first time I click on my app's icon, the form opens correctly.
firstopen.png

However, once I close this application using the cross button and then click on the button from the apps menu again, this time the sidebar opens on the right and I get this message "Content not available for this message". I get no error logs in execution or logs console. In fact, it seems in the 'Executions' panel on the 'Apps Script' console, I am not even getting the 'onOpen' event.

nextopen.png

Can someone please suggest if I am doing something obviously wrong.

Thanks,
Saurabh

Alex

unread,
Jan 23, 2023, 4:36:30 AM1/23/23
to Google Apps Script Community
Hi Saurabh!

Firstly you have to check what do you pass to the sidebar while opening.

It looks like you are sending different values during and after the first open. It can be either an initialization function or a cache read or something even simpler like a range reading. Look at the conditions at startup.

Cheers!

Saurabh Mathur

unread,
Jan 23, 2023, 4:52:14 AM1/23/23
to Google Apps Script Community
Hi Alex,

Thanks for your reply!

So I am always passing the HTML created from my ui.html file. The only trigger function I have is onOpen which I have shown above. I guess in some sense my question is how to differentiate between the first and later opens. Is there another trigger event I need to handle ? My onOpen function is not even getting triggered on subsequent opens.

I am sorry, I didn't follow the checking initial conditions part. Can you please explain that a bit.

Cheers,
Saurabh

Master From Porter

unread,
May 4, 2023, 6:35:38 PM5/4/23
to Google Apps Script Community
Is there any solution to this. I have the same issue!

Alex

unread,
May 9, 2023, 11:52:38 AM5/9/23
to Google Apps Script Community
I think it's a two different ways for show sidebars. The first is HtmlService. The second is CardService. You have to create a sidebar for the CardService too.
Reply all
Reply to author
Forward
0 new messages