Execute specific function based in external script

Here is a example of a pattern for executing a specific function when using external scripts.

Why? Because sometimes you want to manage a single script file (something like myScript.js), and all your different functions are in that one file, but you only want to call a specific function per script action (listener, task, etc). So how do we do this?

Using Local Variables we create a Input Parameter on the Task:

and out external script looks something like this:

var calledFunction = execution.getVariableLocal('scriptFunction');

function Helpers(){};

Helpers.prototype.createIncident = function() {
  // script goes here
  return 'did something';

Helpers.prototype.doSomethingElse = function() {
  // script goes here
  return 'did something else';

var helpers = new Helpers;
var func = calledFunction;

You can change the Helpers to whatever namespace you want. Add more prototypes as needed.
When the script executes it gets the execution’s local variable scriptFunction (which you can change to whatever you want).