Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google apps script for Spreadsheets: How to hide a helper function in Script manager?

I have customised a menu in Google Spreadsheet using Google Apps Script.

The problem I have is that all the helper functions I am using are listed when I press Script Manager.

I would like to hide them, I have read that if I put an underscore at the end of the function name, but it didn't work.

From documentation they say that the underscore at the end makes that the function is only callable from another function and not the editor, but as you can see in the image, it is not working for me: imagen con funciones

like image 366
netadictos Avatar asked Oct 28 '25 00:10

netadictos


2 Answers

The underscore does nothing more than inhibit the function from showing in the Run from Script Editor dropdown.

Running functions. Any function can be invoked directly from the Script Editor, except those with a name that ends with an underscore, which can only be called from other functions.

You cannot hide code in the script editor.

like image 189
ScampMichael Avatar answered Oct 29 '25 13:10

ScampMichael


It should be possible to wrap your functions in a class and then it's not discoverable as a callable function.

// Call it anything.
class HiddenMethods {}

And then where you define your function add it to this class.

HiddenMethods.doSomething = function (someParameter) {
  console.log(someParameter);
}

And to call it

function opOpen() {
  HiddenMethods.doSomething("hey");
}

like image 34
simesy Avatar answered Oct 29 '25 14:10

simesy