Search code examples
google-apps-scriptgoogle-apps-script-editor

How to Pass The Values of Function Parameters and run Standalone Google Apps Script?


From the documentation, https://developers.google.com/apps-script/guides/standalone

Running a standalone script

After writing a script, there are two ways to run a function from the script editor:

  • Select the Run menu, followed by the name of the function you want to execute.

  • Choose the name of the function you want to execute from the select box in the toolbar, then click ▶.

It does not tell us how to pass the parameter values to the functions I want to run.

So how could I pass the parameter values to the functions and run these functions?


Solution

  • The Google Apps Script editor Run feature doesn't offer a direct way to pass parameters to functions so we have to create a helper function to be called by this feature which in time will call the function of interest with the required parameters.

    The above is the that we should do to test trigger functions that require an event object as parameter as is described on How can I test a trigger function in GAS?