Scripting Modules
Scripting modules are used to build a library for common functions. All module can be called from any script including client side form scripts.
Modules are created at process level and every module has a name to distinguish from other modules.
For a module you can configure following properties;
Name Name of module. Module name must be a valid JavaScript identifier, cannot contain space and other scripting identifiers.
Content Content of module
Exporting Functions¶
Common module definition can be defined as below;
function privateSum(a,b) { return a + b; } function sum(a,b) { return privateSum(a,b); } exports.sum = sum;
If you want to expose a function to outside of module, function must be included in "exports" definition. All other functions are considered as "private" to module.
Calling Module Functions¶
To call a function in a module module name must be specified as below;
var result = MyModule.sum(2,3); // result = 5
Client side script modules are always executed as asynchronous context because of browser limitations. To call same function as client side function must be renamed as below;
MyModule.sumAsync(2,3).then(function(result) { // result = 5 });