Used for handling process-related events in simple standard cases without writing Java code. It allows you to flexibly restrict process-editing rules and automatically executed operations in the configuration. Implemented by one or more rules in the process type configuration with the following structure:
onProcessEvent.{@inc:cnt}.events=<EVENTS>
onProcessEvent.{@cnt}.eventsExclude=<EVENTS_EXCLUDE>
# if the class if defined, then the rest of keys is not used
onProcessEvent.{@cnt}.class=<CLASS>
onProcessEvent.{@cnt}.doExpression=<DO_EXPRESSION>
# optional
onProcessEvent.{@cnt}.ifExpression=<IF_EXPRESSION>
onProcessEvent.{@cnt}.checkExpression=<CHECK_EXPRESSION>
onProcessEvent.{@cnt}.checkErrorMessage=<CHECK_ERROR_MESSAGE>
Where:
<EVENTS> - events handled by the rule, separated by semicolons; if the key is omitted, all events related to the given process type are processed;
<EVENTS_EXCLUDE> - events excluded from rule processing, separated by semicolons; if the key is omitted, no events are excluded;
<CLASS> - a Custom class implementing org.bgerp.app.event.iface.EventListener and performing all the logic; prefer the way in case you have more than few lines inside <IF_EXPRESSION>;
<IF_EXPRESSION> - a JEXL condition expression that runs the <DO_EXPRESSION> when satisfied;
<CHECK_EXPRESSION> - a JEXL condition expression; if it evaluates to false, an error <CHECK_ERROR_MESSAGE> is generated and used only together with checkErrorMessage;
<CHECK_ERROR_MESSAGE> - the error text reported when the <CHECK_EXPRESSION> condition fails;
<DO_EXPRESSION> - the executed JEXL script.
| The previously used key commands is no longer supported and must be replaced with doExpression. |
The following events are supported in <EVENTS>:
| Event | Description | event class |
|---|---|---|
|
statusChanging:<STATUS_IDS> |
The process status is changing to one of the values whose IDs are specified as a comma-separated list in <STATUS_IDS> |
|
|
descriptionAdding |
Text is being added to the process description. |
|
|
descriptionChanging |
The process description is being changed in full. |
|
|
executorsChanging |
Process executors are being changed. |
|
|
linkAdding |
A link is being added to the process. |
|
|
linkRemoving |
A process link is being removed. |
|
|
paramChanging:<PARAM_IDS> |
A process parameter whose code is specified as a comma-separated list in <PARAM_IDS> is being changed. |
|
|
statusChanged:<STATUS_IDS> |
The process status has changed to one of the values whose IDs are specified as a comma-separated list in <STATUS_IDS> |
|
|
created |
Process was created. |
|
|
createFinished |
Process creation has been completed in the Wizard |
|
|
createdAsLink |
The process was created as linked to another process. |
|
|
removed |
Process was removed. |
|
|
descriptionAdded |
Text was added to the process description. |
|
|
descriptionChanged |
The process description was changed in full. |
|
|
executorsChanged |
Process executors were changed. |
|
|
linkAdded |
A link was added to the process. |
|
|
linkRemoved |
A process link was removed. |
|
|
messageAdded |
A new message was received in the process. |
|
|
paramChanged:<PARAM_IDS> |
A process parameter whose ID is specified as a comma-separated list in <PARAM_IDS> has changed. |
The *ing events differ from the *ed events in that they are generated before the data is written to the database.
Rules are checked in the order of their numbers. The first rule that emits a message interrupts the check and cancels the process-related change.
The JEXL processor uses Standard Process Context.
| Detailed information about all available objects (including default one, whose called without dot) and their methods in Java Doc can be found at the link above. Keep the page open when working with JEXL. |
For this case the JEXL context has one more object;
event - the event class, extending org.bgerp.event.base.UserEvent
The restrictions are explained in checkErrorMessage values.
onProcessEvent.{@inc:cnt}.checkExpression=p.getStatusId() !~ [9, 13, 36,39] or 8 =~ user.getGroupIds()
onProcessEvent.{@cnt}.checkErrorMessage=In this status, editing is allowed only for Contact Center users
onProcessEvent.{@inc:cnt}.checkExpression=p.getStatusId() != 9 or user.getId() =~ p.getExecutorIds() or 33 =~ user.getPermsetIds()
onProcessEvent.{@cnt}.checkErrorMessage=In this status, editing is allowed only for process executors or the Contact Center administrator
onProcessEvent.{@inc:cnt}.checkExpression=p.getCloseTime() == null
onProcessEvent.{@cnt}.checkErrorMessage=Editing a closed process is prohibited
Add the current user to executors and set the status to 40 when the process was created as linked to another process.
onProcessEvent.{@inc:cnt}.events=createdAsLink
onProcessEvent.{@cnt}.doExpression=addExecutors({user.getId()});setStatus(40, "")
With ID 2 and 37 respectively.
onProcessEvent.{@inc:cnt}.events=<EVENTS>
onProcessEvent.{@cnt}.doExpression=<<END
deleteExecutors({2});
deleteGroups({37});
END
When the status changes to 10 or 12, set the priority to 5.
onProcessEvent.{@inc:cnt}.events=statusChanged:10,12
onProcessEvent.{@cnt}.doExpression=setPriority(5);
Change process status to 3 when receiving a new incoming message to a process.
onProcessEvent.{@inc:cnt}.events=messageAdded
onProcessEvent.{@cnt}.ifExpression=p.getStatusId() != 3
onProcessEvent.{@cnt}.doExpression=setStatus(3, "")
onProcessEvent.{@inc:cnt}.events=statusChanging
onProcessEvent.{@cnt}.doExpression=<<END
change = event.getStatusChange();
change = ctxUserMap[change.getUserId()].getTitle() + " => " + ctxProcessStatusMap[change.getStatusId()].getTitle() + " [" + change.getComment() + "]";
setDescription(p.getDescription() + NEW_LINE + change);
END
Accessing process parameters is performed via pp or processParam object of class org.bgerp.dao.expression.ParamExpressionObject. Reading string representation of values is performed by a call pp.val (23 is a parameter ID of supported type):
value = pp.val(23);
There are special methods like addressCityIds and listValueIds for obtaining value codes.
Set a value from a string can be done with pp.sval (25 is a parameter ID of type date):
pp.sval(25, "01.01.2027");
To generate parameter changing events, can be processed by kernel or plugin:
pp.e().sval(25, "01.01.2027");
The most flexible way to change parameter values is using org.bgerp.dao.param.ParamValueDAO class (63 - a list parameter value):
dao = new("org.bgerp.dao.param.ParamValueDAO", conSet.getConnection());
dao.updateParamList(process.getId(), 63, {1});