8.2 Manual:Extension/Workflows/Tutorial and Manual:Extension/Workflows: Difference between pages

(Difference between pages)
No edit summary
Tag: 2017 source edit
 
No edit summary
 
Line 1: Line 1:
{{DISPLAYTITLE:Creating a custom workflow}}
<bookshelf src="Book:User manual" />
==Introduction==
In BlueSpice 4.1, workflows are based on [[:de:Business_Process_Model_and_Notation|BPMN 2.0]]. Four different types of page-based workflows are already integrated. Their purpose is a page review to obtain feedback via a user vote or to trigger a page approval. In the following, these workflows are therefore called review workflows.


== Defining the workflow  ==
{| class="wikitable" style="width:100%;"
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.
|+Types of reviews
! style="width:300px;" |Workflow type
! style="width:100px;" |Participants
!Description
|-
| style="width:300px;" |'''[[Manual:Extension/Workflows#Single user approval|Single user approval]]'''
| style="width:100px;" |1 user
|A single user is asked to vote about a page.  If a user submits a positive vote, the page is automatically approved.
|-
| style="width:300px;" |'''[[Manual:Extension/Workflows#Expert document control|Expert document control]]'''
| style="width:100px;" |3 users
|After a page has been edited by a specific user, the page is reviewed by an expert and then approved by a  user who is responsible for approvals.
|-
| style="width:300px;" |'''[[Manual:Extension/Workflows#Goup Feedback|Group feedback]]'''
| style="width:100px;" |1 group
|A group (which needs to exist in the group manager) is requested to leave a comment on a page.
|-
| style="width:300px;" |'''[[Manual:Extension/Workflows#Single user feedback|Single user feedback]]'''
| style="width:100px;" |1 user
|A user is asked to send a comment regarding a page.
|}


The described workflow consists of three activities and one gateway. You can create a BPMN-Diagramm in the wiki to visualize the process:
==Workflow activities==
[[File:Workflows-tutorial-diagram.svg|center|thumb|700x700px|alt=Document classification workflow|Document classification workflow]]
All approval workflows start with a form where the necessary workflow data is entered by the workflow initiator. Each workflow results in one or more workflow activities.


== Steps ==
===Single user approval===
To create the workflow, the following steps are necessary:
'''Purpose:''' Approval of a draft page by a user with approval rights. This workflow only makes sense if the approval function ([[Reference:FlaggedRevs|FlaggedRevs]]) is activated on a page.


# Creating a custom '''workflow definition:''' <code>MediaWiki:Classification-workflow.bpmn</code>
'''Workflow instances:''' Only one approval workflow can run per page.
# 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>
# Adding a '''trigger''' to the wiki that defines where and how to start the workflow.


== Instructions ==
[[File:Manual:bpmn-SingleUserApproval.svg|center|thumb|750x750px|BPMN diagram of a "Single user approval" workflow|alt=BPMN diagram of a "Single user approval" workflow]]
{| class="wikitable" style="width:100%;"
! style="width:200px;" |Activity
!Description
|-
| style="width:200px;" | CollectData
|In the first workflow step, the workflow initiator enters the settings:


=== Creating a custom workflow definition ===
*''User:'' ser who is assigned to the task.
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:
*''Instructions:'' A comment or instructions for the user to understand the task.
*''Send report to:'' An email report with the results will be sent to this email address when the review is finished. If a username is specified here, an email address must be stored in the user administration so that the report can be sent.
|-
| style="width:200px;" |PageCheckout
|The page is locked for editing by other wiki users. Only the user  with the workflow task can edit while this workflow is running.
|-
| style="width:200px;" |UserVote
|The assigned user carries out a vote and either accepts the page or rejects it. Alternatively, the task can be delegated. In the event of a rejection, the workflow skips the next step (ApprovePage).
|-
| style="width:200px;" | ApprovePage
|'''Only if''' the user has submitted a positive vote (accept), the page is set to an approved state.
|-
| style="width:200px;" |SendMail
|An email report is sent to the report recipient who was specified in the first step.
|-
| style="width:200px;" |PageCheckin
|The page is unlocked.
|}
{{Icon|bi bi-arrow-right-circle|||}}  [https://github.com/wikimedia/mediawiki-extensions-BlueSpiceDistributionConnector/blob/4.1.3/workflow/UserApproval.bpmn View BPMN]
===Expert document control===
'''Purpose:''' Approval of a draft page according to the "4-eyes principle".


* Line 1: The xml prolog
'''Workflow instances:''' A page can only have one approval worfklow at a time.
* 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 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.
<syntaxhighlight lang="xml" line="1">
<?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">
[[File:Manual:bpmn-ExpertDocControl.svg|center|thumb|550x550px|BPMN diagram of the "Expert document control" workflow|alt=BPMN diagram of the "Expert document control" workflow]]
<bpmn:outgoing>FromTheStartToInitializeWorkflow</bpmn:outgoing>
{| class="wikitable" style="width:100%;"
</bpmn:startEvent>
! style="width:200px;" |Activity
<bpmn:sequenceFlow id="FromTheStartToInitializeWorkflow" sourceRef="TheStart" targetRef="InitializeWorkflow" />
! Description
|- style="height:25px;"
| style="width:200px;" |CollectData
|In the first workflow step, the workflow initiator enters the settings:
''User:'' User who is assigned to a task. Three different users have to be specified: '''Editor''', '''Reviewer''', '''Approver'''


        <!-- ... -->
''Instructions:'' A comment or instructions for the users to understand their tasks.


<bpmn:endEvent id="TheEnd">
''Send report to:'' An email report with the results will be sent to this email address when the review is finished. If a username is specified here, an email address must be stored in the user administration so that the report can be sent.
<bpmn:incoming>FromSendMailToTheEnd</bpmn:incoming>
|-
</bpmn:endEvent>
| style="width:200px;" | PageCheckout
|The page is locked for users who do not participate in the workflow. Only the '''Editor''' (first workflow participant) and '''Reviewer''' (second participant)  of the workflow can edit the page during checkout.
|-
| style="width:200px;" |EditPage
|The '''Editor''' user can edit the page and completes the task without comment.
|-
| style="width:200px;" |UserVote
|After the '''Edito'''r step has been completed,the '''Reviewer''' user can edit the page and submit a vote. As an alternative, the '''Reviewer''' can delegate the task.  If the vote is positive (Approve), the workflow continues. If the '''Reviewer''' rejects, the workflow goes back to the '''Editor'''.
|-
| style="width:200px;" |PageCheckin
|After the '''Reviewer''' submits a positive vote (accept), the page is checked in and the workflow continues.
|-
| style="width:200px;" |PageCheckout
|In this step, the page checkout locks the page for editing completely. The '''Approver''' user will not be able to change the page, but needs to approve it.
|-
| style="width:200px;" |ApprovePage
|The Approver can either complete or delegate the task. After the '''Approver''' (or the delegate) finishes the assigned task, the page is set from "draft" to "approved" status if the page was in draft status (only if the approver submits a positive vote). If not, this step is skipped.
|-
| style="width:200px;" |SendMail
|If an email or user was specified in the workflow settings, the report is now getting sent to that user.
|-
| style="width:200px;" |PageCheckin
|The page gets unlocked for editing.
|}


</bpmn:process>
<span><span /><span /><br /></span>
{{Icon|bi bi-arrow-right-circle|||}}  [https://github.com/wikimedia/mediawiki-extensions-BlueSpiceDistributionConnector/blob/4.1.3/workflow/DocumentControl.bpmn view BPMN]


</bpmn:definitions>
===Group feedback===
</syntaxhighlight>
'''Purpose:''' Obtaining feedback from the  members of a user group. The group must exist in the [[Reference:BlueSpiceGroupManager|group manager]].
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 ====
'''Workflow instances:''' Several feedback workflows can run independently of one another on one page at the same time.
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.
[[File:Manual:bpmn-GroupFeedback..svg|center|thumb|450x450px|BPMN diagram of the "Group feedback" workflow|alt=BPMN diagram of the "Group feedback" workflow]]
{| class="wikitable" style="width:100%;"
! style="width:200px;" |Activity
!Description
|-
| style="width:200px;" | CollectData
| In the first workflow step, the workflow initiator enters the settings:


[[Datei:WF-Tutorial initForm.png|alternativtext=Worfklow initiation form|zentriert|mini|550x550px|Worfklow initiation form]]
* ''Group:'' User group who is assigned to the task.
To create the initiation form:
* ''Instructions:'' A comment or instructions for the users to understand their task.
* S''end report to:'' An email report with the results will be sent to this email address when the review is finished. If a username is specified here, an email address must be stored in the user administration so that the report can be sent.
|-
| style="width:200px;" |GroupFeedback
|All users in the assigned group provide feedback via a comment field. This is a parallel workflow, which means that the order of the feedback does not matter.
|-
| style="width:200px;" |SendMail
|If an email or user was specified in the workflow settings, the report is now getting sent to that user.
|}


# '''Create''' the page <code>MediaWiki:ContentClassificationInit</code>
{{Icon|bi bi-arrow-right-circle|||}}  [https://github.com/wikimedia/mediawiki-extensions-Workflows/blob/4.1.1/workflow/GroupFeedback.bpmn view BPMN]
# '''Paste''' the following form definition in source edit mode:<syntaxhighlight lang="json">


    "lang": "json",
===Feedback===
    "form_name": "ContentClassificationInit",
'''Purpose:''' Obtaining feedback from a single user on a page.  
    "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"
        }
    ]
}


</syntaxhighlight>
'''Workflow instances:''' Multiple feedback worfklows can run independently of one another on one page at the same time.
# '''Save''' the page.


Next, we tell the BPMN with the following userTask to show the form: <syntaxhighlight lang="xml">
[[File:Manual:bpmn-UserFeedback.svg|center|thumb|500x500px|BPMN diagram of the "Single user feedback" workflow|alt=BPMN diagram of the "Single user feedback" workflow]]
<bpmn:userTask id="InitializeWorkflow" name="Start Content Classification Workflow">
{| class="wikitable" style="width:100%;"
<bpmn:extensionElements>
! style="width:200px;" |Activity
<wf:type>custom_form</wf:type>
!Description
<wf:form>MediaWiki:ContentClassificationInit</wf:form>
|-
<wf:initializer>true</wf:initializer>
| style="width:200px;" |CollectData
</bpmn:extensionElements>
|In the first workflow step, the workflow initiator enters the settings:
<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" />


</syntaxhighlight>Let's look at what this does:  
* ''User:'' User who is assigned to the task.
* ''Instructions:'' A comment or instructions for the users to understand their task.
* Send report to: An email report with the results will be sent to this email address when the review is finished. If a username is specified here, an email address must be stored in the user administration so that the report can be sent.
|-
| style="width:200px;" | UserFeedback
|The assigned user sends a comment.
|-
| style="width:200px;" |SendMail
|If an email or user was specified in the workflow settings, the report is now getting sent to that user.
|}


* 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.
{{Icon|bi bi-arrow-right-circle|||}}  [https://github.com/wikimedia/mediawiki-extensions-Workflows/blob/4.1.1/workflow/UserFeedback.bpmn view BPMN]


* <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.
==Overview page==
* <wf:form> points to the actual form page in the wiki
All workflows in the wiki are listed on the page ''Special:Workflows overview''. A view for all ''active'' workflows and a view for ''all'' workflows can be selected.
* <wf:initializer> is set to ''true'' since it is used to show or collect some information before the actual workflow starts.  
[[File:Manual:wf-overview.png|alt=Workflows overview page|center|thumb|650x650px|Workflows overview page]]
=== Tasks overview===
Users are informed about new and pending tasks in their notifications. They can view assigned workflows on their  [[Reference:UnifiedTaskOverview|''My tasks'']]  page.


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).
== Notifications ==


<span><span /><span /><span /><br /></span>
=== Events that trigger notifications ===
We add this '''userTask''' on line 16, after the line  ''<bpmn:sequenceFlow id="FromTheStartToInitializeWorkflow" sourceRef="TheStart" targetRef="InitializeWorkflow" />'':<syntaxhighlight lang="xml" line="1">
There are two types of events that trigger notification
<?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">
* '''generic:''' notifications happen for every workflow/activity type
        <bpmn:outgoing>FromTheStartToInitializ</bpmn:outgoing>
* '''activity-specifiy''': activities themselves can decide to send additional notifications
        </bpmn:startEvent>
      <bpmn:sequenceFlow id="FromTheStartToInitializeWorkflow" sourceRef="TheStart" targetRef="InitializeWorkflow" />


<bpmn:userTask id="InitializeWorkflow" name="Start Content Classification Workflow">
{| class="wikitable" style=""
<bpmn:extensionElements>
!Triggering event
<wf:type>custom_form</wf:type>
!Recipients
<wf:form>MediaWiki:ContentClassificationInit</wf:form>
!Generic
<wf:initializer>true</wf:initializer>
!Notes
</bpmn:extensionElements>
|-
<bpmn:property name="comment"></bpmn:property>
|'''Task started'''
<bpmn:incoming>FromTheStartToInitializeWorkflow</bpmn:incoming>
(task assigned)
<bpmn:outgoing>FromInitializeWorkflowToAskForClassification</bpmn:outgoing>
|All assigned users
</bpmn:userTask>
|Yes
<bpmn:sequenceFlow id="FromInitializeWorkflowToAskForClassification" sourceRef="InitializeWorkflow" targetRef="AskForClassification" />
|Only triggered for type ''UserInteractiveActivity,'' i.e., only for activities that have users assigned.
|-
|'''Workflow aborted'''
(manual or automatic)
|Initiator and all users that were assigned to the current task at time of aborting (not users who were assigned on previous tasks)
|Yes
|
|-
|'''Workflow ended'''
(only when naturally ended, not when aborted)
|Initiator
|Yes
|
|-
|'''DueDateClose'''
(2 days before Workflow will expire)
|Initiator and all currently assigned users
|Yes
|
|-
|'''Workflow expired'''
|Initiator and all currently assigned users
|Yes
|Expiration is just a type of workflow abort, so the same notification as for abort will be sent with the reason explaining that the workflow expired.
|-
|'''Task delegated'''
|User to whom the task was delegated
|No
|Specific to ''UserVote'' activity. After delegation, the newly assigned user will be considered assigned and will receive all further notifications that go out to assigned users.
|}


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


</bpmn:process>
* Users can choose whether to subscribe to e-mail notifications in their preferenceds. All users are force-subscribed to web notifications.
* Web notifications are sent out immediatelly after triggering, while email notifications will be sent async, on runJobs.php execution. This applies to notifications in general, not only to workflows


</bpmn:definitions>
== Workflow triggers ==
</syntaxhighlight>
Workflows can either be started manually on each wiki page or started only under certain conditions using individual [[Manual:Extension/Workflows/Triggers|workflow triggers]]. Triggers also allow to define in which namespaces both manual and automatic workflows are available.


==== Creating and connecting the classification form ====
==How to add a custom workflow==
The workflow will show a classification form to a user. This user will be defined in the workflow in a later step.
Users can upload an xml-file of a BPMN diagram with custom activities to the wiki. Currently, the following predefined activities exist:


To create the classification form:  
'''Extension: Workflows'''


# '''Create''' the page <code>MediaWiki:ContentClassificiationRequest.form</code>
*[[Manual:Extension/Workflows/Activity/CustomForm|CustomForm]]
# '''Paste''' the following form definition in source edit mode:
*[[Manual:Extension/Workflows/Activity/UserVote|UserVote]]
<syntaxhighlight lang="json">
*[[Manual:Extension/Workflows/Activity/GroupVote|GroupVote]]
{
*[[Manual:Extension/Workflows/Activity/UserFeedback|UserFeedback]]
"lang": "json",
*[[Manual:Extension/Workflows/Activity/GrouppFeedback|GroupFeedback]]
"form_name": "ContentClassificationRequest",
*[[Manual:Extension/Workflows/Activity/SendMail|SendMail]]
"items": [
*[[Manual:Extension/Workflows/Activity/EditRequest|EditRequest]]
{
"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
}
]
}
</syntaxhighlight>


Next, we tell the BPMN to show the form to user that receives the workflow task. For that, we add a ''userTask'' activity:
<span><span /><span /><br /></span>
<syntaxhighlight lang="xml">
'''Extension: PageCheckout'''
        ...
<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" />
...
</syntaxhighlight>


We should have a close look. This userTask has some additional properties besides the form reference (which was already explained in the initiation form):
*[[Manual:Extension/Workflows/Activity/PageCheckOut|PageCheckOut]]
*[[Manual:Extension/Workflows/Activity/PageCheckIn|PageCheckIn]]


* '''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>.
<span><span /><span /><br /></span>
* '''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.
'''Extension: BlueSpiceFlaggedRevsConnector'''
* '''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.
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 ====
*[[Manual:Extension/Workflows/Activity/ApprovePage|ApprovePage]]
Now we can proceed with adding the gateway.


The gateway will provide the two necessary paths:
Example of a customized workflow (coming soon)


# If the assigned user classified the document as Class A (CLSA), an email will be sent to the legal department.
<span><span /><span /><br /></span>
# 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"
== Permissions ==
<syntaxhighlight lang="xml">
The following permissions are used by this extension:
        ...
{| class="wikitable" style=""
<bpmn:exclusiveGateway id="Gateway" name="AskForClassification.classification">
|+
<bpmn:incoming>FromAskForClassificationToGateway</bpmn:incoming>
!Permission
<bpmn:outgoing>FromGatewayToSendMail</bpmn:outgoing>
!Included in role
<bpmn:outgoing>FromGatewayToAppendWikipage</bpmn:outgoing>
!Description
</bpmn:exclusiveGateway>
|-
<bpmn:sequenceFlow id="FromGatewayToSendMail" name="CLSA" sourceRef="Gateway" targetRef="SendMail" />
|<span class="ve-pasteProtect" style="color: rgb(51, 64, 85)">workflows-view</span>
<bpmn:sequenceFlow id="FromGatewayToAppendWikipage" name="CLSB" sourceRef="Gateway" targetRef="AppendWikipage" />
|reader
...
|
</syntaxhighlight>
* <span class="ve-pasteProtect" style="color: rgb(51, 64, 85)">allows viewing workflow elements, including listing of workflows (e.g., viewing all running workflows on a page</span>
* user can view the page ''Special:Workflows_overview''
|-
|workflows-execute
|editor, reviewer, admin
|
* allows starting a workflow and executing a task
|-
|workflows-admin
|admin
|
* allows aborting, restoring and administering all workflows
* user fcdan view and edit the page ''MediaWiki:WorkflowTriggers''
|}


After setting up the gateway, we need to define the tworelated activities.
== Example tutorial ==
You can follow our [[Manual:Extension/Workflows/Tutorial|tutorial for creating a custom workflow]] that allows users to classify a document and notify a user about the classification.


==== Sending an mail to the legal department ====
For case 1, we need the workflow to immediately send an email:<syntaxhighlight lang="xml">
        ...
<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 "Class A" 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" />
...
</syntaxhighlight>


==== Appending a wikipage ====
{{translation}}
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:<syntaxhighlight lang="xml">
        ...
<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" />
...
</syntaxhighlight>
 
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: s''ets this page revision as a minor revision (1) or major revision (2).
 
<span><span /><span /><span /><br /></span>
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:<syntaxhighlight lang="xml" line="1">
<?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>FromTheStartToAskForClassification</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="FromTheStartToAskForClassification" sourceRef="TheStart" targetRef="AskForClassification" />
 
<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" />
 
<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 "Class A" 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>
</syntaxhighlight>
 
workflows-activity-editpage-summary
 
== Creating a workflow trigger ==
For the workflow to appear in the wiki, we need to define a trigger:
 
# '''Click''' ''Workflow triggers'' in the Global actions menu.
# '''Click''' ''Add new trigger''.
# '''Select''' the option ''Manual'' from the dropdown menu.
# '''Click''' ''Continue''.
# '''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.
# '''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 [https://bpmn.io/ bpmn.io] service. The resulting [[Medium:Workflows-tutorial-raw.bpmn.xml|bpmn file]] needs to be modified, before it can actually be imported and used in the wiki.

Revision as of 15:41, 11 January 2023

Introduction

In BlueSpice 4.1, workflows are based on BPMN 2.0. Four different types of page-based workflows are already integrated. Their purpose is a page review to obtain feedback via a user vote or to trigger a page approval. In the following, these workflows are therefore called review workflows.

Types of reviews
Workflow type Participants Description
Single user approval 1 user A single user is asked to vote about a page. If a user submits a positive vote, the page is automatically approved.
Expert document control 3 users After a page has been edited by a specific user, the page is reviewed by an expert and then approved by a user who is responsible for approvals.
Group feedback 1 group A group (which needs to exist in the group manager) is requested to leave a comment on a page.
Single user feedback 1 user A user is asked to send a comment regarding a page.

Workflow activities

All approval workflows start with a form where the necessary workflow data is entered by the workflow initiator. Each workflow results in one or more workflow activities.

Single user approval

Purpose: Approval of a draft page by a user with approval rights. This workflow only makes sense if the approval function (FlaggedRevs) is activated on a page.

Workflow instances: Only one approval workflow can run per page.

BPMN diagram of a "Single user approval" workflow
BPMN diagram of a "Single user approval" workflow
Activity Description
CollectData In the first workflow step, the workflow initiator enters the settings:
  • User: ser who is assigned to the task.
  • Instructions: A comment or instructions for the user to understand the task.
  • Send report to: An email report with the results will be sent to this email address when the review is finished. If a username is specified here, an email address must be stored in the user administration so that the report can be sent.
PageCheckout The page is locked for editing by other wiki users. Only the user with the workflow task can edit while this workflow is running.
UserVote The assigned user carries out a vote and either accepts the page or rejects it. Alternatively, the task can be delegated. In the event of a rejection, the workflow skips the next step (ApprovePage).
ApprovePage Only if the user has submitted a positive vote (accept), the page is set to an approved state.
SendMail An email report is sent to the report recipient who was specified in the first step.
PageCheckin The page is unlocked.

View BPMN

Expert document control

Purpose: Approval of a draft page according to the "4-eyes principle".

Workflow instances: A page can only have one approval worfklow at a time.

BPMN diagram of the "Expert document control" workflow
BPMN diagram of the "Expert document control" workflow
Activity Description
CollectData In the first workflow step, the workflow initiator enters the settings:

User: User who is assigned to a task. Three different users have to be specified: Editor, Reviewer, Approver

Instructions: A comment or instructions for the users to understand their tasks.

Send report to: An email report with the results will be sent to this email address when the review is finished. If a username is specified here, an email address must be stored in the user administration so that the report can be sent.

PageCheckout The page is locked for users who do not participate in the workflow. Only the Editor (first workflow participant) and Reviewer (second participant) of the workflow can edit the page during checkout.
EditPage The Editor user can edit the page and completes the task without comment.
UserVote After the Editor step has been completed,the Reviewer user can edit the page and submit a vote. As an alternative, the Reviewer can delegate the task. If the vote is positive (Approve), the workflow continues. If the Reviewer rejects, the workflow goes back to the Editor.
PageCheckin After the Reviewer submits a positive vote (accept), the page is checked in and the workflow continues.
PageCheckout In this step, the page checkout locks the page for editing completely. The Approver user will not be able to change the page, but needs to approve it.
ApprovePage The Approver can either complete or delegate the task. After the Approver (or the delegate) finishes the assigned task, the page is set from "draft" to "approved" status if the page was in draft status (only if the approver submits a positive vote). If not, this step is skipped.
SendMail If an email or user was specified in the workflow settings, the report is now getting sent to that user.
PageCheckin The page gets unlocked for editing.


view BPMN

Group feedback

Purpose: Obtaining feedback from the members of a user group. The group must exist in the group manager.

Workflow instances: Several feedback workflows can run independently of one another on one page at the same time.

BPMN diagram of the "Group feedback" workflow
BPMN diagram of the "Group feedback" workflow
Activity Description
CollectData In the first workflow step, the workflow initiator enters the settings:
  • Group: User group who is assigned to the task.
  • Instructions: A comment or instructions for the users to understand their task.
  • Send report to: An email report with the results will be sent to this email address when the review is finished. If a username is specified here, an email address must be stored in the user administration so that the report can be sent.
GroupFeedback All users in the assigned group provide feedback via a comment field. This is a parallel workflow, which means that the order of the feedback does not matter.
SendMail If an email or user was specified in the workflow settings, the report is now getting sent to that user.

view BPMN

Feedback

Purpose: Obtaining feedback from a single user on a page.

Workflow instances: Multiple feedback worfklows can run independently of one another on one page at the same time.

BPMN diagram of the "Single user feedback" workflow
BPMN diagram of the "Single user feedback" workflow
Activity Description
CollectData In the first workflow step, the workflow initiator enters the settings:
  • User: User who is assigned to the task.
  • Instructions: A comment or instructions for the users to understand their task.
  • Send report to: An email report with the results will be sent to this email address when the review is finished. If a username is specified here, an email address must be stored in the user administration so that the report can be sent.
UserFeedback The assigned user sends a comment.
SendMail If an email or user was specified in the workflow settings, the report is now getting sent to that user.

view BPMN

Overview page

All workflows in the wiki are listed on the page Special:Workflows overview. A view for all active workflows and a view for all workflows can be selected.

Workflows overview page
Workflows overview page

Tasks overview

Users are informed about new and pending tasks in their notifications. They can view assigned workflows on their My tasks page.

Notifications

Events that trigger notifications

There are two types of events that trigger notification

  • generic: notifications happen for every workflow/activity type
  • activity-specifiy: activities themselves can decide to send additional notifications
Triggering event Recipients Generic Notes
Task started

(task assigned)

All assigned users Yes Only triggered for type UserInteractiveActivity, i.e., only for activities that have users assigned.
Workflow aborted

(manual or automatic)

Initiator and all users that were assigned to the current task at time of aborting (not users who were assigned on previous tasks) Yes
Workflow ended

(only when naturally ended, not when aborted)

Initiator Yes
DueDateClose

(2 days before Workflow will expire)

Initiator and all currently assigned users Yes
Workflow expired Initiator and all currently assigned users Yes Expiration is just a type of workflow abort, so the same notification as for abort will be sent with the reason explaining that the workflow expired.
Task delegated User to whom the task was delegated No Specific to UserVote activity. After delegation, the newly assigned user will be considered assigned and will receive all further notifications that go out to assigned users.

Sending out notifications

  • Users can choose whether to subscribe to e-mail notifications in their preferenceds. All users are force-subscribed to web notifications.
  • Web notifications are sent out immediatelly after triggering, while email notifications will be sent async, on runJobs.php execution. This applies to notifications in general, not only to workflows

Workflow triggers

Workflows can either be started manually on each wiki page or started only under certain conditions using individual workflow triggers. Triggers also allow to define in which namespaces both manual and automatic workflows are available.

How to add a custom workflow

Users can upload an xml-file of a BPMN diagram with custom activities to the wiki. Currently, the following predefined activities exist:

Extension: Workflows


Extension: PageCheckout


Extension: BlueSpiceFlaggedRevsConnector

Example of a customized workflow (coming soon)


Permissions

The following permissions are used by this extension:

Permission Included in role Description
workflows-view reader
  • allows viewing workflow elements, including listing of workflows (e.g., viewing all running workflows on a page
  • user can view the page Special:Workflows_overview
workflows-execute editor, reviewer, admin
  • allows starting a workflow and executing a task
workflows-admin admin
  • allows aborting, restoring and administering all workflows
  • user fcdan view and edit the page MediaWiki:WorkflowTriggers

Example tutorial

You can follow our tutorial for creating a custom workflow that allows users to classify a document and notify a user about the classification.




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

No categories assignedEdit

Discussions