enuchi / React-Google-Apps-Script

This is your boilerplate project for developing React apps inside Google Sheets, Docs, Forms and Slides projects. It's perfect for personal projects and for publishing complex add-ons in the Google Workspace Marketplace.
MIT License
1.32k stars 171 forks source link

How to expose an Appscript ServerFunction to the user for attaching as a script? #220

Closed pradeep-gox closed 3 months ago

pradeep-gox commented 4 months ago

Hi there,

I would like to expose an Appscript server function (eg., openSidebar) to the user, so that when the user installs my add-on, instead of launching the sidebar ui from Extensions drop-down, I would like to create a button in a sheet and attach the script function openSidebar to it. So when the user clicks the button, it should launch the sidebar ui.

Any help would be appreciated 👍

enuchi commented 4 months ago

The docs explain how to do this. You could type in for example openAboutSidebar under "Assign script" if you are using this boilerplate.

https://developers.google.com/apps-script/guides/menus#clickable_images_and_drawings_in

pradeep-gox commented 4 months ago

I am able to do it in development. I think its because of the 'clasp push' to the appscript attached to my development spreadsheet. But when I install my add-on from the marketplace (production), the function is not available to be used on any spreadsheet.

pradeep-gox commented 3 months ago

Found that I should make the script access visible to everyone to achieve this.

Btw thanks for your support 🙂