BPM adds new node definitions JCR. If you are installing plugin BPM in a Ametys application that already contains data, delete the AMETYS_HOME/data/repository/repository/nodetypes/custom_nodetypes file.xml before restarting the server.
Technical integration
Creating workflow templates
To create workflows for your processes, you first need to define worflow definitions (or templates).
BPM workflow definitions are XML workflow files in the usual sense Ametys, with a list of states, transitions and variables. Variables are used to parameterize the workflow, for example to define the people assigned to transitions.
Workflow files used by the BPM module must be declared with a workflow name prefixed with "bpm-". See Workflow settings page
Variable declaration
plugin BPM lets you define variables in workflow definition files.
Variables are defined in the <registers>at the root of the <workflow>. They are of type="avalon", with any unique "variable-name" in the file.
Example of variables
Oops!
Copy to clipboard failed. Open the code and copy it manually.
type: mandatory, defines the type of the variable. "user" is probably the most commonly used type, although "string" or "date" are perfectly valid.
label, description: mandatory, key i18n representing the label and description displayed in CMS when a workflow is created, so you know what the variable corresponds to.
variableId: mandatory, used as identifier to store variable value. Must be unique among all workflow variables. A good practice is to use the same value for "variable-name" and "variableId".
multiple: falcultative, "false" by default, to allow multiple values
mandatory: optional, "false" by default, the value "true" is used to force the variable to be filled in when the workflow is created.
Using variables
The variables defined can then be used in workflow actions in the format: ${variable-name}.
For example, to authorize a transition only for users defined in the variable ${FirstUsersForValidation} we write :
Oops!
Copy to clipboard failed. Open the code and copy it manually.
To start the process, an initialization action id=1 must be present in the <initial-actions>
Here's an example of an initialization action. In this example, a mail will be sent following process creation to the people defined in the variables ${allowedRepresentatives} and ${allowExperts}
Oops!
Copy to clipboard failed. Open the code and copy it manually.
Action with id=2 is reserved for modifying the process (to change attachments, for example). It must contain the pre-functionorg.ametys.plugins.bpm.process.EditProcessFunction
Action 2 is optional, if you don't want processes to be modifiable after creation.
To enable a process to be modified regardless of its current state, you can create a common action, as shown in the example below. In this example, modifying a process does not modify its current state; the process remains in its current state.
Oops!
Copy to clipboard failed. Open the code and copy it manually.
A process is complete when it reaches its final state. A final state is a state (step) in which no action is possible.
A terminated process can be deleted by its creator.
Assigning people to transitions
To authorize a transition (workflow action) to one or more persons defined by a variable, you must use the condition org.ametys.plugins.bpm.workflowsdef.CheckAllowedUsersCondition
This condition checks that the logged-in user is one of the users authorized by the variable (in this case $allowExperts). If this is not the case, the action will not be available to the current user.
Oops!
Copy to clipboard failed. Open the code and copy it manually.
To authorize a transition (workflow action) to the process creator, you must use the condition org.ametys.plugins.bpm.workflowsdef.CheckProcessCreatorCondition
This condition verifies that the logged-in user is the process creator. If this is not the case, the action will not be available to the current user.
Oops!
Copy to clipboard failed. Open the code and copy it manually.
users: pass a variable containing one or more users to be notified by mail (optional)
sendToCreator: true or false (false by default) If "true", the process creator will be notified by mail (optional)
subjectKey key 18n (set) for the title of the message sent. Possible parameters are :
0: process name
bodyKey: key 18n (set) for the content of the message sent. Possible parameters are :
0: user responsible for transition (the creator if the process has just been created)
1: process creator
2: process name
3: link to the process consultation page
Example of a i18n key for sending mail
Oops!
Copy to clipboard failed. Open the code and copy it manually.
<message key="WORKFLOW_BPM_MAIL_BODY_ACTION_DESC">{0} a effectué une action sur le processus {2}. Pour vous rendre sur la page du processus, cliquez ou copiez-collez le lien ci-après {3}.</message>
<message key="WORKFLOW_BPM_MAIL_BODY_ACTION_DESC">{0} a effectué une action sur le processus {2}. Pour vous rendre sur la page du processus, cliquez ou copiez-collez le lien ci-après {3}.</message>
<message key="WORKFLOW_BPM_MAIL_BODY_ACTION_DESC">{0} a effectué une action sur le processus {2}. Pour vous rendre sur la page du processus, cliquez ou copiez-collez le lien ci-après {3}.</message>
Update current workflow status
Each action (transition) must contain the post-function org.ametys.plugins.bpm.workflow.SetProcessCurrentStepId
This function saves the current state on the process itself.
Oops!
Copy to clipboard failed. Open the code and copy it manually.
This example corresponds to a process requiring double validation (by an expert and an elected representative). The order of validation is irrelevant, so there are 2 possible paths to complete the process.
In the example given:
Experts and elected representatives are notified by email as soon as the process is created.
Upon validation by an expert, elected representatives are notified by email.
Upon validation by an elected official, experts are notified by email.
The process can be modified at any stage by the creator himself.
You can download the plugin key definition i18n corresponding to this workflow here: default-bpm-workflow.zip
Graphic integration
Process visualization
To view a process, the page template used is determined in the following order:
use of the"bpm-process" template if it exists in the current charter
otherwise, use the template on the page labelled "Process creation" if it exists
otherwise, use the "page" template if it exists in the current charter
otherwise use 1st template found.
To override the rendering of a process, create the file skins/SKIN_NAME/services/bpm/pages/process.xsl
This file must contain at least :
Oops!
Copy to clipboard failed. Open the code and copy it manually.