public class RulePlugin extends AbstractPlugin
// test first value of the workitem attribute 'txtname'
var isValid = ('Anna'==workitem.txtname[0]);
A script can add new values for the current workitem by providing the JSON
object 'result'.
var result={ someitem:'Hello World', somenumber:1};
Also change values of the event object can be made by the script. These
changes will be reflected back for further processing.
// disable mail
event.keymailenabled='0';
A script can set the variables 'isValid' and 'followUp' to validate a
workItem or set a new followUp activity.
result={ isValid:false };
If the script set the variable 'isValid' to false then the plugin throws a
PluginExcpetion. The Plugin evaluates the variables 'errorCode' and
errorMessage. If these variables are set by the Script then the
PluginException will be updates with the corresponding errorCode and the
'errorMessage' as params[]. If no errorCode is set then the errorCode of the
PluginException will default to 'VALIDATION_ERROR'.
If the script set the variable 'followUp' the follow-up behavior of the
current ActivityEntity will be updated.
If a script can not be evaluated by the scriptEngin a PluginExcpetion with
the errorCode 'INVALID_SCRIPT' will be thrown.
NOTE: all variable names are case sensitive! All JSON object elements are
lower case!| Modifier and Type | Field and Description |
|---|---|
static String |
INVALID_SCRIPT |
static String |
VALIDATION_ERROR |
INVALID_ITEMVALUE_FORMAT, INVALID_PROPERTYVALUE_FORMAT| Constructor and Description |
|---|
RulePlugin() |
| Modifier and Type | Method and Description |
|---|---|
ScriptEngine |
evaluateBusinessRule(ItemCollection documentContext,
ItemCollection activity)
This method evaluates the business rule defined by the provided activity.
|
Object[] |
evaluateNativeScriptArray(ScriptEngine engine,
String expression)
This method evaluates a script variable as an native Script array from
the script engine.
|
ItemCollection |
run(ItemCollection adocumentContext,
ItemCollection adocumentActivity)
The run method evaluates a script provided by an activityEntity with the
specified scriptEngine.
|
close, formatItemValues, formatItemValues, getCtx, getWorkflowService, init, mergeFieldList, mergeValueList, replaceDynamicValues, uniqueListpublic static final String INVALID_SCRIPT
public static final String VALIDATION_ERROR
public ItemCollection run(ItemCollection adocumentContext, ItemCollection adocumentActivity) throws PluginException
PluginExceptionpublic ScriptEngine evaluateBusinessRule(ItemCollection documentContext, ItemCollection activity) throws PluginException
adocumentContext - adocumentActivity - PluginExceptionpublic Object[] evaluateNativeScriptArray(ScriptEngine engine, String expression)
Copyright © 2006–2017 Imixs Software Solutions GmbH. All rights reserved.