Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Script modules are used to define common use library functions. Modules can be called from pre work, post work like server environment or form and validation rule like client environment.

Modules always executed in isolated environment and does not automatically import any variable.

Define a Script Module

  1. Click to "+" icon from "Script Modules"
  2. Specify the module name. Because module name used in script environment whitespace or other punctuation chars cannot be used.
  3. Modify the module content as following script
function privateSum(a,b) {
    return a+b;
}


function publicSum(a,b) {
	return privateSum(a,b);
}

exports.sum = publicSum;

Parameter Types

Module parameters must be serializable primitive types like string, date, number or object. Other complex types like xml node or functions cannot be used as a parameter.

Exporting Module Functions

Modules may contain one or more functions to structure content and reusability but not all functions are exported to outside of module. If you want to expose a function to outside world, function must be added to "exports" object.

Calling Module Function

Module functions called in "ModuleName.FunctionName(arguments)" syntax. For above example you call function as following sample;

var result = MyModule.sum(1,2);

Client Side Module Calls

Modules are always executed as synchronous context in server environment but because of browser limitations client side modules renamed as "functionAsync" and return a javascript promise object to support asynchronous context. For example same module can be called as following example;

MyModule.sumAsync(1,2).then(function(result) {
    // result = 3
});




  • No labels