I have some basic custom menus I create in my Google Apps Script Editor:
// Script has a library added under Resources -> Libraries -> [library1]
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('MyMenu').addItem('Refresh Data', 'refresh_the_data').addToUi();
}
function refresh_the_data(){
library1.refresh();
}
The menu appears for me (the developer) but doesn't appear when I share the Sheet with other users.
The onOpen() function uses an external library in the 'refresh_the_data' function. When running onOpen() as a different user, I get the error 'You do not have access to library library1, used by your script, or it has been deleted.'
So I can share 'library1' with all users who need access to this script. Is there a better way to share script functionality with an Add-on or an App? Ideally I would like to keep the library private (not expose the full code of the library) although I understand I have to expose the code if I want other users to use the functionality.