This Action executes a Nashorn script.
The Action is implemented by the Java class de.ecm4u.faw.api.impl.NashornAction.
The Action has one required parameter:
NashornAction.scriptName: The Textresource name of the Nashorn Script to execute.The Action has one optional parameter:
NashornAction.importJavaScriptLibraries: an array of JavaScript libraries (as Textresources) that shall be loaded into the context of the script.In addition, custom parameters can be set to inject scalar values into the script context.
Custom.myName: The scalar value of this parameter will be available as myName in the script context.NashornAction.scriptName: the-script.js
NashornAction.importJavaScriptLibraries:
- underscore.min.js
- moment.min.js
- the-library.js
Custom.formId: "$formd0"
The Nashorn script must contain a function run that takes no arguments. This function must
return a Result Object.
function run() {
// Execute script logic.
// ...
// Must return result object.
return {
success: true,
message: "OK"
};
}
The run function must return a result object. To indicate success, return this:
var result = {
result: true,
message: "OK"
}
To indicate an error, return a complex object with details about the error(s).
var result = {
success: false, // Did this script succeed?
message: "Message that describes this result.",
strategies: ["FAIL"], // "FAIL" and "RETRY are supported.
errors: [ // Optional array of error detail objects.
{
component: "formData", // The compont/service/object that was used.
method: "get", // The method that was called on the component.
parameters: { // The parameters used for the method.
key: "filingCase" // Arbitrary key/value pairs.
},
message: "Form " + formId + " does not have 'filingCase.'", // Detailed error message.
classification: "FS-002: formData property not set" // Classification of this error.
}
]
};