Manual:Extension/Workflows/Tutorial: Difference between revisions

No edit summary
Tag: 2017 source edit
No edit summary
 
(14 intermediate revisions by 3 users not shown)
Line 4: Line 4:
Let's assume, we want to build a workflow, that asks for some classification of a wikipage. Based on the classification of the document, it either sends an e-mail to a member of the legal team or it first appends a wiki page and then sends the e-mail to the legal team.
Let's assume, we want to build a workflow, that asks for some classification of a wikipage. Based on the classification of the document, it either sends an e-mail to a member of the legal team or it first appends a wiki page and then sends the e-mail to the legal team.


The described workflow consists of three activities and one gateway. You can create a BPMN-Diagramm in the wiki to visualize the process:
The described workflow consists of four activities and one gateway. You can create a BPMN-Diagramm in the wiki to visualize the process:
[[File:Workflows-tutorial-diagram.svg|center|thumb|700x700px|alt=Document classification workflow|Document classification workflow]]
[[File:Workflows-tutorial-diagram.svg|center|thumb|700x700px|alt=Document classification workflow|Document classification workflow]]


== Steps ==
==Steps==
To create the workflow, the following steps are necessary:
To create the workflow, the following steps are necessary:


# Creating a custom '''workflow definition:''' <code>MediaWiki:Classification-workflow.bpmn</code>
#Creating a custom '''workflow definition:''' <code>MediaWiki:Classification-workflow.bpmn</code>
# Creating and connecting an '''initiation form''' that adds some information about the workflow before it sends the task. <code>MediaWiki:ContentClassificationInit.form</code>
#Creating and connecting an '''initiation form''' that adds some information about the workflow before it sends the task. <code>MediaWiki:ContentClassificationInit.form</code>
# Creating and connecting the '''classification form''' that allows the assigned user to classify the document. <code>MediaWiki:ContentClassificiationRequest.form</code>
#Creating and connecting the '''classification form''' that allows the assigned user to classify the document. <code>MediaWiki:ContentClassificationRequest.form</code>
# Adding a '''trigger''' to the wiki that defines where and how to start the workflow.
#Adding a '''trigger''' to the wiki that defines where and how to start the workflow.


== Instructions ==
==Instructions==


=== Creating a custom workflow definition ===
{{Textbox|boxtype=important|header=Note|text=XML which is provided below is incompatible with "BPMN Editor" added in BlueSpice 4.5. There is no way to edit it in visual way.|icon=yes}}
 
===Creating a custom workflow definition===
First, let's create a page called <code>MediaWiki:Classification-workflow.bpmn</code> with the most basic stub XML. Each workflow that you define in the wiki needs the elements that you see here:
First, let's create a page called <code>MediaWiki:Classification-workflow.bpmn</code> with the most basic stub XML. Each workflow that you define in the wiki needs the elements that you see here:


* Line 1: The xml prolog
*Line 1: The XML prolog
* Line 2: The definitions element, which denotes the namespaces where the workflow elements are defined.
*Line 2: The definitions element, which denotes the namespaces where the workflow elements are defined.
* Line3: The process element, which contains all other elements.
*Line 3: The process element, which contains all other elements.
* Line 5: The workflow runs in the context of a specific revision of a wiki page.
*Line 5: The workflow runs in the context of a specific revision of a wiki page.
* Line 11: The workflow needs a startEvent and
* Line 11: The workflow needs a startEvent and
* Line 18: The workflow needs an endEvent.
*Line 18: The workflow needs an endEvent.
<syntaxhighlight lang="xml" line="1">
<syntaxhighlight lang="xml" line="1">
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:wf="http://hallowelt.com/schema/bpmn/wf">
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:wf="http://hallowelt.com/schema/bpmn/wf" xmlns:di="http://www.omg.org/spec/DD/20100524/DI">
<bpmn:process id="Classification_workflow_process">
<bpmn:process id="Classification_workflow_process">
    <bpmn:extensionElements>
    <bpmn:extensionElements>
Line 38: Line 40:


    <bpmn:startEvent id="TheStart">
    <bpmn:startEvent id="TheStart">
<bpmn:outgoing>FromTheStartToInitializeWorkflow</bpmn:outgoing>
<bpmn:outgoing>FromTheStartToTheEnd</bpmn:outgoing>
</bpmn:startEvent>
</bpmn:startEvent>
<bpmn:sequenceFlow id="FromTheStartToInitializeWorkflow" sourceRef="TheStart" targetRef="InitializeWorkflow" />
<bpmn:sequenceFlow id="FromTheStartToTheEnd" sourceRef="TheStart" targetRef="TheEnd" />


         <!-- ... -->
         <!-- ... -->


<bpmn:endEvent id="TheEnd">
<bpmn:endEvent id="TheEnd">
<bpmn:incoming>FromSendMailToTheEnd</bpmn:incoming>
<bpmn:incoming>FromTheStartToTheEnd</bpmn:incoming>
</bpmn:endEvent>
</bpmn:endEvent>


Line 54: Line 56:
The above stub xml only features the "Start" and "End" event including - yet to be defined - "outgoing" and "incoming" flow references.
The above stub xml only features the "Start" and "End" event including - yet to be defined - "outgoing" and "incoming" flow references.


==== Creating and connecting an initiation form ====
====Creating and connecting an initiation form====
The initiation form allows to interact with the user who starts the workflow. It explains what happens when the workflow is started and allows to add a comment to provide some context for the user task.
The initiation form allows to interact with the user who starts the workflow. It explains what happens when the workflow is started and allows to add a comment to provide some context for the user task.


Line 62: Line 64:
To create the initiation form:
To create the initiation form:


# '''Create''' the page <code>MediaWiki:ContentClassificationInit</code>
#'''Create''' the page <code>MediaWiki:ContentClassificationInit.form</code>
# '''Paste''' the following form definition in source edit mode:<syntaxhighlight lang="json">
#'''Paste''' the following form definition in source edit mode:<syntaxhighlight lang="json">
 
{
     "lang": "json",
     "lang": "json",
     "form_name": "ContentClassificationInit",
     "form_name": "ContentClassificationInit",
Line 92: Line 94:


</syntaxhighlight>
</syntaxhighlight>
# '''Save''' the page.
#'''Save''' the page.


Next, we tell the BPMN with the following userTask to show the form: <syntaxhighlight lang="xml">
Next, we tell the BPMN with the following userTask to show the form: <syntaxhighlight lang="xml">
Line 109: Line 111:
</syntaxhighlight>Let's look at what this does:  
</syntaxhighlight>Let's look at what this does:  


* The <code>id</code> and <code>name</code> of this activity are set to "InitializeWorkflow"  and "Start Content Classification Workflow". Both values do not need to match, but usually they do.
*The <code>id</code> and <code>name</code> of this activity are set to "InitializeWorkflow"  and "Start Content Classification Workflow". Both values do not need to match, but usually they do.


* <wf:type> is ''custom_form'' and tells the workflow that a form directly in the wiki (as opposed to a form located in code) is available.
*<wf:type> is ''custom_form'' and tells the workflow that a form directly in the wiki (as opposed to a form located in code) is available.
* <wf:form> points to the actual form page in the wiki
*<wf:form> points to the actual form page in the wiki
* <wf:initializer> is set to ''true'' since it is used to show or collect some information before the actual workflow starts.  
* <wf:initializer> is set to ''true'' since it is used to show or collect some information before the actual workflow starts.


At the end, we have the incoming and outgoing flows referenced. (Note: the order of elements does not matter usually; only the nesting is important).
At the end, we have the incoming and outgoing flows referenced. (Note: the order of elements does not matter usually; only the nesting is important).


<span><span /><span /><span /><br /></span>
<span><span /><span /><span /><span /><span /><span /><span /><br /></span>
We add this '''userTask''' on line 16, after the line  ''<bpmn:sequenceFlow id="FromTheStartToInitializeWorkflow" sourceRef="TheStart" targetRef="InitializeWorkflow" />'':<syntaxhighlight lang="xml" line="1">
We add this '''userTask''' on line 16, after the line  ''<bpmn:sequenceFlow id="FromTheStartToInitializeWorkflow" sourceRef="TheStart" targetRef="InitializeWorkflow" />'':<syntaxhighlight lang="xml" line="1">
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
Line 155: Line 157:
</syntaxhighlight>
</syntaxhighlight>


==== Creating and connecting the classification form ====
====Creating and connecting the classification form====
The workflow will show a classification form to a user. This user will be defined in the workflow in a later step.  
The workflow will show a classification form to a user. This user will be defined in the workflow in a later step.  


To create the classification form:  
To create the classification form:  


# '''Create''' the page <code>MediaWiki:ContentClassificiationRequest.form</code>
#'''Create''' the page <code>MediaWiki:ContentClassificationRequest.form</code>
# '''Paste''' the following form definition in source edit mode:
#'''Paste''' the following form definition in source edit mode:
<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
{
{
Line 218: Line 220:
We should have a close look. This userTask has some additional properties besides the form reference (which was already explained in the initiation form):
We should have a close look. This userTask has some additional properties besides the form reference (which was already explained in the initiation form):


* '''assigned user:'''  The <code>assigned_user</code> property is mandatory,  as the workflow engine must know which user to query.  In this case, we use some wikitext magic to calculate the assigned user from the context. The value consists of a combination of a wikitext variable and a parserfunction (this particular parserfunction is defined by the Semantic MediaWiki extension, which can be seen as a dependency here). The <code><nowiki>{{#show}}</nowiki></code> parserfunction tries to get a username from a semantic property, that may or may not be set on the page the workflow is started on. If it does not find a proper information, it will fallback to <code>TheBoss</code> (assuming that such a user exists on the wiki). The <code><nowiki>{{ROOTPAGE}}</nowiki></code> variable is just an easy way to strip the "User" namespace, if the looked up value was something like <code>User:JaneDoe</code> instead of just <code>JaneDoe</code>.
*'''assigned user:'''  The <code>assigned_user</code> property is mandatory,  as the workflow engine must know which user to query.  In this case, we use some wikitext magic to calculate the assigned user from the context. The value consists of a combination of a wikitext variable and a parserfunction (this particular parserfunction is defined by the Semantic MediaWiki extension, which can be seen as a dependency here). The <code><nowiki>{{#show}}</nowiki></code> parserfunction tries to get a username from a semantic property, that may or may not be set on the page the workflow is started on. If it does not find a proper information, it will fallback to <code>TheBoss</code> (assuming that such a user exists on the wiki). The <code><nowiki>{{ROOTPAGENAME}}</nowiki></code> variable is just an easy way to strip the "User" namespace, if the looked up value was something like <code>User:JaneDoe</code> instead of just <code>JaneDoe</code>.
* '''due date:''' The <code>due_date</code> property is also mandatory. All user facing activities need a due date. If the running activity is overdue, the workflow engine will end the workflow. In this case, we implement a concept of "lay days", as we do not have an absolute due date, but calculate it from the time the activity gets started using the <code><nowiki>{{#time}}</nowiki></code> parserfunction.
*'''due date:''' The <code>due_date</code> property is also mandatory. All user facing activities need a due date. If the running activity is overdue, the workflow engine will end the workflow. In this case, we implement a concept of "lay days", as we do not have an absolute due date, but calculate it from the time the activity gets started using the <code><nowiki>{{#time}}</nowiki></code> parserfunction.
* '''classification:'''
*'''classification:''' The <code>classification</code> property is a random one. It must be specified, in order to allow the form to set it and the workflow context to access it. We could have provided a default value, but we want to keep it empty.
* The <code>classification</code> property is a random one. It must be specified, in order to allow the form to set it and the workflow context to access it. We could have provided a default value, but we want to keep it empty.
At the end, we have the incoming and outgoing flows referenced. (Note: the order of elements does not matter usually; only the nesting is important).
At the end, we have the incoming and outgoing flows referenced. (Note: the order of elements does not matter usually; only the nesting is important).


====The gateway ====
==== The gateway====
Now we can proceed with adding the gateway.
Now we can proceed with adding the gateway.


The gateway will provide the two necessary paths:
The gateway will provide the two necessary paths:  


# If the assigned user classified the document as Class A (CLSA), an email will be sent to the legal department.
#If the assigned user classified the document as Class A (CLSA), an email will be sent to the legal department.
# If the assigned user classified the document as Class B (CLSB), a wiki page will be appended with the content defined in the task "AppendWikipage"
#If the assigned user classified the document as Class B (CLSB), a wiki page will be appended with the content defined in the task "AppendWikipage"
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
         ...
         ...
Line 245: Line 246:
After setting up the gateway, we need to define the tworelated activities.
After setting up the gateway, we need to define the tworelated activities.


==== Sending an mail to the legal department ====
====Sending an mail to the legal department====
For case 1, we need the workflow to immediately send an email:<syntaxhighlight lang="xml">
For case 1, we need the workflow to immediately send an email:<syntaxhighlight lang="xml">
         ...
         ...
Line 256: Line 257:
</bpmn:property>
</bpmn:property>
<bpmn:property name="subject">
<bpmn:property name="subject">
<![CDATA[New "Class A" content: {{FULLPAGENAME}}]]>
<![CDATA[New "{{{AskForClassification.classification}}}" content: {{FULLPAGENAME}}]]>
</bpmn:property>
</bpmn:property>
<bpmn:property name="body">
<bpmn:property name="body">
Line 269: Line 270:
</syntaxhighlight>
</syntaxhighlight>


==== Appending a wikipage ====
====Appending a wikipage ====
For case 2, we want the workflow to append the existing page ''Classification_incidents'' with the text shown in the ''content'' property.  
For case 2, we want the workflow to append the existing page ''Classification_incidents'' with the text shown in the ''content'' property.  


Line 279: Line 280:
</bpmn:extensionElements>
</bpmn:extensionElements>
<bpmn:property name="title" default="Classification_incidents"/>
<bpmn:property name="title" default="Classification_incidents"/>
<bpmn:property name="user" default="Mediawiki default"/>
<bpmn:property name="user" default="MediaWiki default"/>
<bpmn:property name="content" default="* [[{{FULLPAGENAME}}]] was classified {{{AskForClassification.classification}}}"/>
<bpmn:property name="content" default="* [[{{FULLPAGENAME}}]] was classified {{{AskForClassification.classification}}}"/>
<bpmn:property name="mode" default="append"/>
<bpmn:property name="mode" default="append"/>
Line 292: Line 293:
The following properties are set for this activity type:
The following properties are set for this activity type:


* ''name:'' title of the wiki page to which the content will be appended.
*''name:'' title of the wiki page to which the content will be appended.
* ''user:'' user that is shown in the version history of the wiki page that was appended.
*''user:'' user that is shown in the version history of the wiki page that was appended.
* ''content:'' text that is added to the wiki page.
*''content:'' text that is added to the wiki page.
* ''mode:'' shows where the text is added to the wiki page (append or ???)
*''mode:'' shows where the text is added to the wiki page (append or ???)
* ''minor: s''ets this page revision as a minor revision (1) or major revision (2).  
*''minor: s''ets this page revision as a minor revision (1) or major revision (2).


<span><span /><span /><span /><br /></span>
<span><span /><span /><span /><span /><span /><span /><span /><br /></span>
After this task is completed, the workflow will send an email to the legal department.
After this task is completed, the workflow will send an email to the legal department.


==== The final BPMN ====
====The final BPMN====
In the end, the bpmn page for the workflow looks like this:<syntaxhighlight lang="xml" line="1">
In the end, the bpmn page for the workflow looks like this:
<syntaxhighlight lang="xml" line="1">
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions
<bpmn:definitions
Line 316: Line 318:
</bpmn:extensionElements>
</bpmn:extensionElements>
<bpmn:startEvent id="TheStart">
<bpmn:startEvent id="TheStart">
<bpmn:outgoing>FromTheStartToAskForClassification</bpmn:outgoing>
<bpmn:outgoing>FromTheStartToInitializeWorkflow</bpmn:outgoing>
</bpmn:startEvent>
</bpmn:startEvent>
<bpmn:sequenceFlow id="FromTheStartToAskForClassification" sourceRef="TheStart" targetRef="AskForClassification" />
<bpmn:sequenceFlow id="FromTheStartToInitializeWorkflow" sourceRef="TheStart" targetRef="InitializeWorkflow" />
<bpmn:userTask id="InitializeWorkflow" name="Start Content Classification Workflow">
<bpmn:extensionElements>
<wf:type>custom_form</wf:type>
<wf:form>MediaWiki:ContentClassificationInit</wf:form>
<wf:initializer>true</wf:initializer>
</bpmn:extensionElements>
<bpmn:property name="comment"></bpmn:property>
<bpmn:incoming>FromTheStartToInitializeWorkflow</bpmn:incoming>
<bpmn:outgoing>FromInitializeWorkflowToAskForClassification</bpmn:outgoing>
</bpmn:userTask>
<bpmn:sequenceFlow id="FromInitializeWorkflowToAskForClassification" sourceRef="InitializeWorkflow" targetRef="AskForClassification" />


<bpmn:userTask id="AskForClassification" name="Provide classification">
<bpmn:userTask id="AskForClassification" name="Provide classification">
Line 324: Line 338:
<wf:type>custom_form</wf:type>
<wf:type>custom_form</wf:type>
<wf:form>MediaWiki:ContentClassificationRequest</wf:form>
<wf:form>MediaWiki:ContentClassificationRequest</wf:form>
<wf:initializer>true</wf:initializer>
</bpmn:extensionElements>
</bpmn:extensionElements>
<bpmn:property name="assigned_user">
<bpmn:property name="assigned_user">
Line 333: Line 346:
</bpmn:property>
</bpmn:property>
<bpmn:property name="classification"></bpmn:property>
<bpmn:property name="classification"></bpmn:property>
<bpmn:incoming>FromTheStartToAskForClassification</bpmn:incoming>
<bpmn:incoming>FromInitializeWorkflowToAskForClassification</bpmn:incoming>
<bpmn:outgoing>FromAskForClassificationToGateway</bpmn:outgoing>
<bpmn:outgoing>FromAskForClassificationToGateway</bpmn:outgoing>
</bpmn:userTask>
</bpmn:userTask>
Line 354: Line 367:
</bpmn:property>
</bpmn:property>
<bpmn:property name="subject">
<bpmn:property name="subject">
<![CDATA[New "Class A" content: {{FULLPAGENAME}}]]>
<![CDATA[New "{{{AskForClassification.classification}}}" content: {{FULLPAGENAME}}]]>
</bpmn:property>
</bpmn:property>
<bpmn:property name="body">
<bpmn:property name="body">
Line 370: Line 383:
</bpmn:extensionElements>
</bpmn:extensionElements>
<bpmn:property name="title" default="Classification_incidents"/>
<bpmn:property name="title" default="Classification_incidents"/>
<bpmn:property name="user" default="Mediawiki default"/>
<bpmn:property name="user" default="MediaWiki default"/>
<bpmn:property name="content" default="* [[{{FULLPAGENAME}}]] was classified {{{AskForClassification.classification}}}"/>
<bpmn:property name="content" default="* [[{{FULLPAGENAME}}]] was classified {{{AskForClassification.classification}}}"/>
<bpmn:property name="mode" default="append"/>
<bpmn:property name="mode" default="append"/>
Line 390: Line 403:
workflows-activity-editpage-summary
workflows-activity-editpage-summary


== Creating a workflow trigger ==
==Creating a workflow trigger==
For the workflow to appear in the wiki, we need to define a trigger:
For the workflow to appear in the wiki, we need to define a trigger:


# '''Click''' ''Workflow triggers'' in the Global actions menu.
#'''Click''' ''Workflow triggers'' in the Global actions menu.
# '''Click''' ''Add new trigger''.
#'''Click''' ''Add new trigger''.
# '''Select''' the option ''Manual'' from the dropdown menu.
#'''Select''' the option ''Manual'' from the dropdown menu.
# '''Click''' ''Continue''.
#'''Click''' ''Continue''.
# '''Define''' the settings for the workflow trigger:
#'''Define''' the settings for the workflow trigger:
#* ''Name:'' Name that is displayed in the workflow selection menu.
#*''Name:'' Name that is displayed in the workflow selection menu.
#* ''Description:'' Explanation of the function and special features of this trigger.
#*''Description:'' Explanation of the function and special features of this trigger.
#* ''Workflow to start:'' Workflow triggered by this trigger. In our case Classificiation-workflow.
#* ''Workflow to start:'' Workflow triggered by this trigger. In our case Classificiation-workflow.
#* ''Initial data for the workflow'' (optional):  - Standard comment suggestion.
#* ''Initial data for the workflow'' (optional):  - Standard comment suggestion.
#* ''Conditions'' (optional)'':'' In which namespaces the workflow is displayed for selection.
#*''Conditions'' (optional)'':'' In which namespaces the workflow is displayed for selection.
# '''Click''' ''Save''.
#'''Click''' ''Save''.
 


<span><span /><span /><span /><br /></span>
Your workflow is now ready to be tested.
Your workflow is now ready to be tested.


== Testing the workflow ==
==Testing the workflow ==
The workflow is now available in the wiki.  You should test whether the following functionality is available:
The workflow is now available in the wiki.  You should test whether the following functionality is available:


* The workflow is available to be started in the namespaces defined in the workflow trigger (if there are restrictions here).
*The workflow is available to be started in the namespaces defined in the workflow trigger (if there are restrictions here).
* The workflow is triggered.
*The workflow is triggered.
* The workflow is listed in the Worklfows Overview page.
*The workflow is listed in the Worklfows Overview page.
* The assigned user received a task.
*The assigned user received a task.
* The workflow completes correctly in case A and B.
*The workflow completes correctly in case A and B.
 
==Using bpmn.io to create workflow definitions ==
Such a diagram can be created with the free [https://bpmn.io/ bpmn.io] service. The [[Media:Manual:Workflows-tutorial-raw.bpmn.xml|resulting BPMN file]] needs to be modified, before it can actually be imported and used in the wiki.


== Using bpmn.io to create workflow definitions ==
[[de:Handbuch:Erweiterung/Workflows/Tutorial]]
Such a diagram can be created with the free [https://bpmn.io/ bpmn.io] service. The resulting bpmn file needs to be modified, before it can actually be imported and used in the wiki.
[[en:{{FULLPAGENAME}}]]

Latest revision as of 09:21, 29 May 2024


Defining the workflow

Let's assume, we want to build a workflow, that asks for some classification of a wikipage. Based on the classification of the document, it either sends an e-mail to a member of the legal team or it first appends a wiki page and then sends the e-mail to the legal team.

The described workflow consists of four activities and one gateway. You can create a BPMN-Diagramm in the wiki to visualize the process:

Document classification workflow
Document classification workflow

Steps

To create the workflow, the following steps are necessary:

  1. Creating a custom workflow definition: MediaWiki:Classification-workflow.bpmn
  2. Creating and connecting an initiation form that adds some information about the workflow before it sends the task. MediaWiki:ContentClassificationInit.form
  3. Creating and connecting the classification form that allows the assigned user to classify the document. MediaWiki:ContentClassificationRequest.form
  4. Adding a trigger to the wiki that defines where and how to start the workflow.

Instructions

NoteXML which is provided below is incompatible with "BPMN Editor" added in BlueSpice 4.5. There is no way to edit it in visual way.


Creating a custom workflow definition

First, let's create a page called MediaWiki:Classification-workflow.bpmn with the most basic stub XML. Each workflow that you define in the wiki needs the elements that you see here:

  • Line 1: The XML prolog
  • Line 2: The definitions element, which denotes the namespaces where the workflow elements are defined.
  • Line 3: The process element, which contains all other elements.
  • Line 5: The workflow runs in the context of a specific revision of a wiki page.
  • Line 11: The workflow needs a startEvent and
  • Line 18: The workflow needs an endEvent.
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:wf="http://hallowelt.com/schema/bpmn/wf" xmlns:di="http://www.omg.org/spec/DD/20100524/DI">
	<bpmn:process id="Classification_workflow_process">
	    <bpmn:extensionElements>
			<wf:context>
				<wf:contextItem name="pageId"/>
				<wf:contextItem name="revision"/>
			</wf:context>
		</bpmn:extensionElements>

	    <bpmn:startEvent id="TheStart">
			<bpmn:outgoing>FromTheStartToTheEnd</bpmn:outgoing>
		</bpmn:startEvent>
		<bpmn:sequenceFlow id="FromTheStartToTheEnd" sourceRef="TheStart" targetRef="TheEnd" />

        <!-- ... -->

		<bpmn:endEvent id="TheEnd">
			<bpmn:incoming>FromTheStartToTheEnd</bpmn:incoming>
		</bpmn:endEvent>

	</bpmn:process>

</bpmn:definitions>

The above stub xml only features the "Start" and "End" event including - yet to be defined - "outgoing" and "incoming" flow references.

Creating and connecting an initiation form

The initiation form allows to interact with the user who starts the workflow. It explains what happens when the workflow is started and allows to add a comment to provide some context for the user task.

We are using the MediaWiki namespace here to make sure not every user can edit the form later. But in general, such forms can be created everywhere in the wiki.

Worfklow initiation form
Worfklow initiation form

To create the initiation form:

  1. Create the page MediaWiki:ContentClassificationInit.form
  2. Paste the following form definition in source edit mode:
    {
        "lang": "json",
        "form_name": "ContentClassificationInit",
        "items": [
            {
                "name": "intro",
                "widget_label": "Click  \"Start\" to ask an expert for classification. You can leave a comment for the expert below",
                "type": "label"
            },
            {
                "name": "comment",
                "label": "Comment",
                "noLayout": true,
                "showOn": [
                    "create",
                    "edit",
                    "view"
                ],
                "editableOn": [
                    "create",
                    "edit"
                ],
                "type": "textarea"
            }
        ]
    }
    
  3. Save the page.

Next, we tell the BPMN with the following userTask to show the form:

		<bpmn:userTask id="InitializeWorkflow" name="Start Content Classification Workflow">
			<bpmn:extensionElements>
				<wf:type>custom_form</wf:type>
				<wf:form>MediaWiki:ContentClassificationInit</wf:form>
				<wf:initializer>true</wf:initializer>
			</bpmn:extensionElements>
			<bpmn:property name="comment"></bpmn:property>
			<bpmn:incoming>FromTheStartToInitializeWorkflow</bpmn:incoming>
			<bpmn:outgoing>FromInitializeWorkflowToAskForClassification</bpmn:outgoing>
		</bpmn:userTask>
		<bpmn:sequenceFlow id="FromInitializeWorkflowToAskForClassification" sourceRef="InitializeWorkflow" targetRef="AskForClassification" />

Let's look at what this does:

  • The id and name of this activity are set to "InitializeWorkflow" and "Start Content Classification Workflow". Both values do not need to match, but usually they do.
  • <wf:type> is custom_form and tells the workflow that a form directly in the wiki (as opposed to a form located in code) is available.
  • <wf:form> points to the actual form page in the wiki
  • <wf:initializer> is set to true since it is used to show or collect some information before the actual workflow starts.

At the end, we have the incoming and outgoing flows referenced. (Note: the order of elements does not matter usually; only the nesting is important).


We add this userTask on line 16, after the line <bpmn:sequenceFlow id="FromTheStartToInitializeWorkflow" sourceRef="TheStart" targetRef="InitializeWorkflow" />:

<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:wf="http://hallowelt.com/schema/bpmn/wf">
	<bpmn:process id="Classification_workflow_process">
	    <bpmn:extensionElements>
			<wf:context>
				<wf:contextItem name="pageId"/>
				<wf:contextItem name="revision"/>
			</wf:context>
		</bpmn:extensionElements>

	    <bpmn:startEvent id="TheStart">
        	<bpmn:outgoing>FromTheStartToInitializ</bpmn:outgoing>
        </bpmn:startEvent>
       <bpmn:sequenceFlow id="FromTheStartToInitializeWorkflow" sourceRef="TheStart" targetRef="InitializeWorkflow" />

		<bpmn:userTask id="InitializeWorkflow" name="Start Content Classification Workflow">
			<bpmn:extensionElements>
				<wf:type>custom_form</wf:type>
				<wf:form>MediaWiki:ContentClassificationInit</wf:form>
				<wf:initializer>true</wf:initializer>
			</bpmn:extensionElements>
			<bpmn:property name="comment"></bpmn:property>
			<bpmn:incoming>FromTheStartToInitializeWorkflow</bpmn:incoming>
			<bpmn:outgoing>FromInitializeWorkflowToAskForClassification</bpmn:outgoing>
		</bpmn:userTask>
		<bpmn:sequenceFlow id="FromInitializeWorkflowToAskForClassification" sourceRef="InitializeWorkflow" targetRef="AskForClassification" />

		<bpmn:endEvent id="TheEnd">
			<bpmn:incoming>FromSendMailToTheEnd</bpmn:incoming>
		</bpmn:endEvent>

	</bpmn:process>

</bpmn:definitions>

Creating and connecting the classification form

The workflow will show a classification form to a user. This user will be defined in the workflow in a later step.

To create the classification form:

  1. Create the page MediaWiki:ContentClassificationRequest.form
  2. Paste the following form definition in source edit mode:
{
	"lang": "json",
	"form_name": "ContentClassificationRequest",
	"items": [
		{
			"name": "intro",
			"widget_label": "Please review the given document and select an appropriate classification for the content from the list below",
			"type": "label"
		},
		{
			"name": "classification",
			"label": "Classification",
			"required": true,
			"options": [
				{
					"data": "CLSA",
					"label": "Class A"
				},
				{
					"data": "CLSB",
					"label": "Class B"
				}
			],
			"type": "dropdown",
			"widget_$overlay": true
		}
	]
}

Next, we tell the BPMN to show the form to user that receives the workflow task. For that, we add a userTask activity:

        ...
		<bpmn:userTask id="AskForClassification" name="Provide classification">
			<bpmn:extensionElements>
				<wf:type>custom_form</wf:type>
				<wf:form>MediaWiki:ContentClassificationRequest</wf:form>
			    <wf:initializer>true</wf:initializer>
			</bpmn:extensionElements>
			<bpmn:property name="assigned_user">
				<![CDATA[{{ROOTPAGENAME:{{#show:{{FULLPAGENAME}}|?Responsible|link=none|default=TheBoss}}}}]]>
			</bpmn:property>
			<bpmn:property name="due_date">
				<![CDATA[{{#time:YmdHis|now + 7 days}}]]>
			</bpmn:property>
			<bpmn:property name="classification"></bpmn:property>
			<bpmn:incoming>FromTheStartToAskForClassification</bpmn:incoming>
			<bpmn:outgoing>FromAskForClassificationToGateway</bpmn:outgoing>
		</bpmn:userTask>
		<bpmn:sequenceFlow id="FromAskForClassificationToGateway" sourceRef="AskForClassification" targetRef="Gateway" />
		...

We should have a close look. This userTask has some additional properties besides the form reference (which was already explained in the initiation form):

  • assigned user: The assigned_user property is mandatory, as the workflow engine must know which user to query. In this case, we use some wikitext magic to calculate the assigned user from the context. The value consists of a combination of a wikitext variable and a parserfunction (this particular parserfunction is defined by the Semantic MediaWiki extension, which can be seen as a dependency here). The {{#show}} parserfunction tries to get a username from a semantic property, that may or may not be set on the page the workflow is started on. If it does not find a proper information, it will fallback to TheBoss (assuming that such a user exists on the wiki). The {{ROOTPAGENAME}} variable is just an easy way to strip the "User" namespace, if the looked up value was something like User:JaneDoe instead of just JaneDoe.
  • due date: The due_date property is also mandatory. All user facing activities need a due date. If the running activity is overdue, the workflow engine will end the workflow. In this case, we implement a concept of "lay days", as we do not have an absolute due date, but calculate it from the time the activity gets started using the {{#time}} parserfunction.
  • classification: The classification property is a random one. It must be specified, in order to allow the form to set it and the workflow context to access it. We could have provided a default value, but we want to keep it empty.

At the end, we have the incoming and outgoing flows referenced. (Note: the order of elements does not matter usually; only the nesting is important).

The gateway

Now we can proceed with adding the gateway.

The gateway will provide the two necessary paths:

  1. If the assigned user classified the document as Class A (CLSA), an email will be sent to the legal department.
  2. If the assigned user classified the document as Class B (CLSB), a wiki page will be appended with the content defined in the task "AppendWikipage"
        ...
		<bpmn:exclusiveGateway id="Gateway" name="AskForClassification.classification">
			<bpmn:incoming>FromAskForClassificationToGateway</bpmn:incoming>
			<bpmn:outgoing>FromGatewayToSendMail</bpmn:outgoing>
			<bpmn:outgoing>FromGatewayToAppendWikipage</bpmn:outgoing>
		</bpmn:exclusiveGateway>
		<bpmn:sequenceFlow id="FromGatewayToSendMail" name="CLSA" sourceRef="Gateway" targetRef="SendMail" />
		<bpmn:sequenceFlow id="FromGatewayToAppendWikipage" name="CLSB" sourceRef="Gateway" targetRef="AppendWikipage" />
		...

After setting up the gateway, we need to define the tworelated activities.

Sending an mail to the legal department

For case 1, we need the workflow to immediately send an email:

        ...
		<bpmn:task id="SendMail" name="Send mail">
			<bpmn:extensionElements>
				<wf:type>send_mail</wf:type>
			</bpmn:extensionElements>
			<bpmn:property name="recipient">
				<![CDATA[legal@company.local]]>
			</bpmn:property>
			<bpmn:property name="subject">
				<![CDATA[New "{{{AskForClassification.classification}}}" content: {{FULLPAGENAME}}]]>
			</bpmn:property>
			<bpmn:property name="body">
				<![CDATA[Please check further actions now!]]>
			</bpmn:property>
			<bpmn:incoming>FromGatewayToSendMail</bpmn:incoming>
			<bpmn:incoming>FromAppendWikipageToSendMail</bpmn:incoming>
			<bpmn:outgoing>FromEndMailToTheEnd</bpmn:outgoing>
		</bpmn:task>
		<bpmn:sequenceFlow id="FromEndMailToTheEnd" sourceRef="SendMail" targetRef="TheEnd" />
		...

Appending a wikipage

For case 2, we want the workflow to append the existing page Classification_incidents with the text shown in the content property.

This requirement can be fulfilled with the edit_page activity type:

        ...
		<bpmn:task id="AppendWikipage" name="Append wikipage">
			<bpmn:extensionElements>
				<wf:type>edit_page</wf:type>
			</bpmn:extensionElements>
			<bpmn:property name="title" default="Classification_incidents"/>
			<bpmn:property name="user" default="MediaWiki default"/>
			<bpmn:property name="content" default="* [[{{FULLPAGENAME}}]] was classified {{{AskForClassification.classification}}}"/>
			<bpmn:property name="mode" default="append"/>
			<bpmn:property name="minor" default="1"/>
			<bpmn:incoming>FromGatewayToAppendWikipage</bpmn:incoming>
			<bpmn:outgoing>FromAppendWikipageToSendMail</bpmn:outgoing>
		</bpmn:task>
		<bpmn:sequenceFlow id="FromAppendWikipageToSendMail" sourceRef="AppendWikipage" targetRef="SendMail" />
		...

The following properties are set for this activity type:

  • name: title of the wiki page to which the content will be appended.
  • user: user that is shown in the version history of the wiki page that was appended.
  • content: text that is added to the wiki page.
  • mode: shows where the text is added to the wiki page (append or ???)
  • minor: sets this page revision as a minor revision (1) or major revision (2).


After this task is completed, the workflow will send an email to the legal department.

The final BPMN

In the end, the bpmn page for the workflow looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions
	xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL"
	xmlns:wf="http://hallowelt.com/schema/bpmn/wf">

	<bpmn:process id="Classification_workflow_process">
		<bpmn:extensionElements>
			<wf:context>
				<wf:contextItem name="pageId"/>
				<wf:contextItem name="revision"/>
			</wf:context>
		</bpmn:extensionElements>
		<bpmn:startEvent id="TheStart">
			<bpmn:outgoing>FromTheStartToInitializeWorkflow</bpmn:outgoing>
		</bpmn:startEvent>
		<bpmn:sequenceFlow id="FromTheStartToInitializeWorkflow" sourceRef="TheStart" targetRef="InitializeWorkflow" />
		
		<bpmn:userTask id="InitializeWorkflow" name="Start Content Classification Workflow">
			<bpmn:extensionElements>
				<wf:type>custom_form</wf:type>
				<wf:form>MediaWiki:ContentClassificationInit</wf:form>
				<wf:initializer>true</wf:initializer>
			</bpmn:extensionElements>
			<bpmn:property name="comment"></bpmn:property>
			<bpmn:incoming>FromTheStartToInitializeWorkflow</bpmn:incoming>
			<bpmn:outgoing>FromInitializeWorkflowToAskForClassification</bpmn:outgoing>
		</bpmn:userTask>
		<bpmn:sequenceFlow id="FromInitializeWorkflowToAskForClassification" sourceRef="InitializeWorkflow" targetRef="AskForClassification" />

		<bpmn:userTask id="AskForClassification" name="Provide classification">
			<bpmn:extensionElements>
				<wf:type>custom_form</wf:type>
				<wf:form>MediaWiki:ContentClassificationRequest</wf:form>
			</bpmn:extensionElements>
			<bpmn:property name="assigned_user">
				<![CDATA[{{ROOTPAGENAME:{{#show:{{FULLPAGENAME}}|?Responsible|link=none|default=TheBoss}}}}]]>
			</bpmn:property>
			<bpmn:property name="due_date">
				<![CDATA[{{#time:YmdHis|now + 7 days}}]]>
			</bpmn:property>
			<bpmn:property name="classification"></bpmn:property>
			<bpmn:incoming>FromInitializeWorkflowToAskForClassification</bpmn:incoming>
			<bpmn:outgoing>FromAskForClassificationToGateway</bpmn:outgoing>
		</bpmn:userTask>
		<bpmn:sequenceFlow id="FromAskForClassificationToGateway" sourceRef="AskForClassification" targetRef="Gateway" />

		<bpmn:exclusiveGateway id="Gateway" name="AskForClassification.classification">
			<bpmn:incoming>FromAskForClassificationToGateway</bpmn:incoming>
			<bpmn:outgoing>FromGatewayToSendMail</bpmn:outgoing>
			<bpmn:outgoing>FromGatewayToAppendWikipage</bpmn:outgoing>
		</bpmn:exclusiveGateway>
		<bpmn:sequenceFlow id="FromGatewayToSendMail" name="CLSA" sourceRef="Gateway" targetRef="SendMail" />
		<bpmn:sequenceFlow id="FromGatewayToAppendWikipage" name="CLSB" sourceRef="Gateway" targetRef="AppendWikipage" />

		<bpmn:task id="SendMail" name="Send mail">
			<bpmn:extensionElements>
				<wf:type>send_mail</wf:type>
			</bpmn:extensionElements>
			<bpmn:property name="recipient">
				<![CDATA[legal@company.local]]>
			</bpmn:property>
			<bpmn:property name="subject">
				<![CDATA[New "{{{AskForClassification.classification}}}" content: {{FULLPAGENAME}}]]>
			</bpmn:property>
			<bpmn:property name="body">
				<![CDATA[Please check further actions now!]]>
			</bpmn:property>
			<bpmn:incoming>FromGatewayToSendMail</bpmn:incoming>
			<bpmn:incoming>FromAppendWikipageToSendMail</bpmn:incoming>
			<bpmn:outgoing>FromEndMailToTheEnd</bpmn:outgoing>
		</bpmn:task>
		<bpmn:sequenceFlow id="FromEndMailToTheEnd" sourceRef="SendMail" targetRef="TheEnd" />

		<bpmn:task id="AppendWikipage" name="Append wikipage">
			<bpmn:extensionElements>
				<wf:type>edit_page</wf:type>
			</bpmn:extensionElements>
			<bpmn:property name="title" default="Classification_incidents"/>
			<bpmn:property name="user" default="MediaWiki default"/>
			<bpmn:property name="content" default="* [[{{FULLPAGENAME}}]] was classified {{{AskForClassification.classification}}}"/>
			<bpmn:property name="mode" default="append"/>
			<bpmn:property name="minor" default="1"/>
			<bpmn:incoming>FromGatewayToAppendWikipage</bpmn:incoming>
			<bpmn:outgoing>FromAppendWikipageToSendMail</bpmn:outgoing>
		</bpmn:task>
		<bpmn:sequenceFlow id="FromAppendWikipageToSendMail" sourceRef="AppendWikipage" targetRef="SendMail" />

		<bpmn:endEvent id="TheEnd">
			<bpmn:incoming>FromSendMailToTheEnd</bpmn:incoming>
		</bpmn:endEvent>

	</bpmn:process>

</bpmn:definitions>

workflows-activity-editpage-summary

Creating a workflow trigger

For the workflow to appear in the wiki, we need to define a trigger:

  1. Click Workflow triggers in the Global actions menu.
  2. Click Add new trigger.
  3. Select the option Manual from the dropdown menu.
  4. Click Continue.
  5. Define the settings for the workflow trigger:
    • Name: Name that is displayed in the workflow selection menu.
    • Description: Explanation of the function and special features of this trigger.
    • Workflow to start: Workflow triggered by this trigger. In our case Classificiation-workflow.
    • Initial data for the workflow (optional): - Standard comment suggestion.
    • Conditions (optional): In which namespaces the workflow is displayed for selection.
  6. Click Save.


Your workflow is now ready to be tested.

Testing the workflow

The workflow is now available in the wiki. You should test whether the following functionality is available:

  • The workflow is available to be started in the namespaces defined in the workflow trigger (if there are restrictions here).
  • The workflow is triggered.
  • The workflow is listed in the Worklfows Overview page.
  • The assigned user received a task.
  • The workflow completes correctly in case A and B.

Using bpmn.io to create workflow definitions

Such a diagram can be created with the free bpmn.io service. The resulting BPMN file needs to be modified, before it can actually be imported and used in the wiki.




To submit feedback about this documentation, visit our community forum.