Call Function

This action is used to call a function defined for the current flow, page, or application (web app). For extensions, it's used to call a function defined for the current flow, page, App UI, or extension. These functions are referred to as module functions, and they're created and edited using the JavaScript editor for a particular scope.

Example

Suppose this function is defined for a page:

PageModule.prototype.sum = function (num1, num2) {
   return num1 + num2;};
};

You can call the function and assign its result, like this:

const sumResult = $page.functions.sum($page.variables.firstNum_pv, $page.variables.secondNum_pv);
For extensions, you can create global functions, which would be available to all App UIs in the extension, and referenced using this syntax, <artifact-scope>.modules.<module-id>.<function-name>. For example:
$application.modules.calculator.add

For more about using global functions in extensions, see Add Global Functions.

Return Values

The result payload is equivalent to whatever the function returns (which may be undefined if there is no return). If the function returns a promise, the result payload will be whatever is resolved in the promise.