Overview
Let's suppose we need two types of workflows: the standard which requires the author, a peer reviewer and the editor to review before considering a document published, and the fast-track which would require only the author and the editor to approve.
The peer reviewers in the standard workflow have to be chosen from two different teams, team A or team B.
The user primus is the only one than can give the final approval.
Defining the workflows
We are going to need three workflows: A default workflow which will be used to select the workflow to use, and two label workflows (workflows associated to a label): one for the standard and one for the fast track.
| selection workflow | to be applied in all the pages on the space |
| standard workflow | This workflow will become active on those pages with the standardworkflow label |
| fast-track workflow | This workflow will become active on those pages with the fasttrack label |
Note that each workflow has to be defined on a different page.
Selection Workflow
The selection workflow will have a {trigger} that will be fired whenever a page is created. We will use the {select-label} macro to prompt for the selection of the workflow. The selection will be set in the view page screen using the {set-caption} macro:
{workflow}
{trigger:pagecreated}
{set-caption}
{select-label:labels=standardworkflow ,fasttrack |
title=Please select workflow|
descriptions=Standard, Fast-track}
{set-caption}
{trigger}
{workflow}
Fast-track Workflow
We need to define a workflow associated with the fasttrack label (only pages with that label will be subject to it).
Then we need to define the approvals: Author and Publish. To give the Publish approval, the Author approval must be given first. We want also to send an email to primus whenever a page is approved:
{workflow:label=fasttrack}
{approval:Author}
{approval:Publish|hasapproval=Author|user=primus}
{trigger:pageapproved|approval=Author}
{send-email:user=primus}The page @page@ has been approved.{send-email}
{trigger}
{workflow}
Standard Workflow
The Standard Workflow is a little bit more complicated. First, we are going to need three approvals: Author, Peer Review and Publish.
We want authors to select the peer reviewer from two teams, so we have to ask users to select the team. To do this, we need to create a {trigger} that will be fired when the standardworkflow label is added, and we will use again the {select-label} and {set-caption} macros to prompt for the selection of the team.
{workflow:label=standardworkflow}
{trigger:labeladded|label=standardworkflow}
{set-caption}
{select-label:labels=team_a ,team_b |
title=Please select the team|
descriptions=Team A, Team B}
{set-caption}
{trigger}
{workflow}
Team A members are auctor and emendator and Team B members are emendator and primus. We are going to use the Metadata Plugin to store the selected team members as a value named Reviewer, which will be used later for the Peer Review approval.
To set the values, we need to create two {trigger}s that will be fired then the team_a and the team_b label are added:
{workflow:label=standardworkflow}
...
{trigger:labeladded|label=team_a}
{metadata:Reviewer}auctor, emendator{metadata}
{trigger}
{trigger:labeladded|label=team_b}
{metadata:Reviewer}primus, emendator{metadata}
{trigger}
...
Now let's define the approvals. The Author approval is the first approval the author has to give when the document is ready for review.
The Peer Review approval can be given after the Author approval is given, and only by whoever is selected from the chosen team. As per the triggers above, we would store the team members in the metadata value Reviewers.
Then we have the Publish approval that can be given only by primus after the Peer Review approval is given.
{workflow:label=standardworkflow}
{approval:Author}
{approval:Peer review|hasapproval=Author|selectedapprover=@Reviewer@}
{approval:Publish|hasapproval=Peer review|user=primus}
...
{workflow}
We defined the Peer review as depending on the Author approval, and to be given by the selected approver from the choices stored in the Reviewer metadata value. The user would have to select the approver when given the Author approval.
Finally, we want to send an email to the select approver, so he/she knows he/she has to give the approval:
{workflow:label=standardworkflow}
...
{trigger:pageapproved|approval=Author}
{send-email:user=@selectedapprover@}You have to review @page@{send-email}
{trigger}
...
{workflow}
The final workflows
Lets just make some fine tuning on the workflows.
First we want to store the workflows on a space other than the one to be used for the content, therefore we have to define on what space the workflows must work, for example lets say the content's Space Key is AWPFT.
We want also to make the Publish approval as final, so we can see the Published tab, which would be the default tab for read-only users.
This is how the workflows would look like. Note that each workflow has to be defined on each page.
The Selection workflow:
{workflow:space=AWPFT}
{trigger:pagecreated}
{set-caption}
{select-label:labels=standardworkflow ,fasttrack |
title=Please select workflow|
descriptions=Standard, Fast-track}
{set-caption}
{trigger}
{workflow}
The Fast-track workflow:
{workflow:space=AWPFT|label=fasttrack}
{approval:Author}
{approval:Publish|hasapproval=Author|user=primus|final=true}
{trigger:pageapproved|approval=Author}
{send-email:user=primus}You have to publish @page@{send-email}
{trigger}
{workflow}
The Standard workflow:
{workflow:space=AWPFT|label=standardworkflow}
{approval:Author}
{approval:Peer review|hasapproval=Author|selectedapprover=@Reviewer@}
{approval:Publish|hasapproval=Peer review|user=primus|final=true}
{trigger:labeladded|label=standardworkflow}
{set-caption}
{select-label:labels=team_a ,team_b |
title=Please select the team|
descriptions=Team A, Team B}
{set-caption}
{trigger}
{trigger:labeladded|label=team_a}
{metadata:Reviewer}auctor, emendator{metadata}
{trigger}
{trigger:labeladded|label=team_b}
{metadata:Reviewer}primus, emendator{metadata}
{trigger}
{trigger:pageapproved|approval=Author}
{send-email:user=@selectedapprover@}You have to review @page@{send-email}
{trigger}
{workflow}
