Change book | Close bookmaker |
WORKFLOW
is set in the topic. WORKFLOW
must be set to the wiki
name of a topic that describes your specific workflow (the _workflow
description topic_).
you can hide the setting in a normal view using HTML comments, or
better, you can put these settings into the local topic settings,
accessible from the "more..." screen. Or you can put the setting into
a formfield - see #FormBasedWorkflows below.
The workflow description topic must contain one state table and one transition table. The state table describes the possible states a document may be in (nodes in the flow diagram above), and the transition table describes how documents move between states (arcs in the flow diagram).
This is easiest illustrated using an example (available as DocumentApprovalWorkflow / ControlledDocument if the plugin is installed).Each row of the state table defines a state that a topic can be in:
| *State* | *Message* | | UNDERREVISION | This document is being revised. | | WAITINGFORQM | This document is waiting for approval by the Quality Manager. | | WAITINGFORCTO | This document is waiting for approval by the CTO.| | APPROVED | This document has been approved for release. |Each row in the table defines a state where:
| *State* | *Action* | *Next State* | *Form* | *Allowed* | | UNDERREVISION | complete | WAITINGFORQM | | QualityGroup | | WAITINGFORQM | approve | WAITINGFORCTO | QaForm | QualityManager | | WAITINGFORQM | reject | UNDERREVISION | QaForm | QualityManager,QualityGroup | | WAITINGFORCTO | approve | APPROVED | QaForm | TechnicalDirector | | WAITINGFORCTO | reject | UNDERREVISION | QaForm | TechnicalDirector,QualityManager | | APPROVED | revise | UNDERREVISION | PuForm | QualityGroup |Each row in this table defines a transition from one state to another state:
UNDERREVISION
state. After finishing the revision, the document can
be transitioned to the WAITINGFORQM
state by any member of the
QualityGroup. It must then be approved by the QualityManager, and
after that by the TechnicalDirector. Even though they can't edit the
document themselves (see state table above), they can reject the
revision and put the document back into the UNDERREVISION
state. The
TechnicalDirector can transition the document to APPROVED
state
where it rests until a member of the QualityGroup puts it under
revision again.
If a form name is given in the Form column, this form will be
attached to the topic, and the topic will put in edit mode to allow
information to be provided in the form when that state transition happens.
In the example above, a form of type ApprovedForm will
be attached to the topic when the CTO transitions the topic into
APPROVED
state. label
field) once a given state is reached.
Any preference settings in the workflow
description topic that start with WORKFLOW
are automatically available
when topics that use that workflow are viewed.
Format | Example |
---|---|
Email addresses | webmaster@example.com |
User wiki names | Main.WikiGuest |
Wiki group names | Main.AdminGroup |
Last user-in-state | LASTUSER_APPROVED |
Last user-in-state expands to the name of the user who last transitioned to the given state.
mailworkflowtransition
skin template. You can override
this by providing a template topic called WorkflowTransitionMailTemplate
in the web where the transitioning topic resides.
In addition you can define custom email templates in the Notify
column, using the syntax template(Web.MyTopic)
. This allows you to
do more sophisticated email notification, for example you could write
a different custom email template for each transition.
For example, the Notify column in the transition table below will email jim@example.com
using the default template, and expand both the EmailOne
and EmailTwo
templates, sending the results to whatever email addresses are defined on their respective To
, Cc
, or Bcc
lines:
| *State* | .... | *Notify* | | PENDING | .... | jim@example.com, template(EmailOne), template(EmailTwo) |Custom templates have the additional macro:
TEMPLATE |
web.topic name of the template |
tools/workflowremind
script. This script is normally run from a cron job, and can be run without parameters to see how it works.
the WORKFLOWDEFAULTEMAILTEMPLATE
preference is no longer supported. Please use local template topics and/or skin templates instead.
WORKFLOW
for it to be controlled under the approval workflow. This is best set as a document-specific preference setting in the More topic actions
screen.
Parameter | Meaning | Default |
---|---|---|
web |
(Optional) name of the web containing the topic |
current web |
topic |
(Optional) name of the topic (may use web.topic syntax) | current topic |
rev
parameter.
If the topic is not controlled, then any references to WORKFLOW
macros are simply removed. You can use this behaviour to place these
tags in the header or footer in your skin templates. They appear only
if the currently displayed topic is controlled.
%WORKATTACHTOPIC%
%WORKFLOWEDITTOPIC%
%WORKFLOWFORK{...}%
Parameter | Meaning | Default |
---|---|---|
newnames="NameOne,NameTwo,..." |
Comma-separated list of name(s) of the new topic(s) to create. AUTOINC is supported, and you can use a web specifier on the topic names. | required, no default. |
label="Fork" |
Label to use in the button | "Fork" |
lockdown="on" |
Set this if you want the forked topic to be set as uneditable by all except admins after the fork. This will also prevent the topic from being forked again. | off |
%WORKFLOWFORK{topic="OriginalTopic" label="Divide and conquer" newnames="ForkPathOne,ForkPathTwo" lockdown="on"}%
will create two copies of OriginalTopic
, named ForkPathOne
and
ForkPathTwo
and set the OriginalTopic
as uneditable (using
ALLOWTOPICCHANGE).
The fork copies do not inherit the history of the forked topic - their history starts afresh with the fork.
due to a bug in versions of the plugin prior to Oct 2009, the default parameter was interpreted as the name of the new topic to fork to. This has been corrected, but the macro will revert to the old meaning if you omit thenewnames
parameter.
%WORKFLOWTRANSITION%
workflowstrings.tmpl
%WORKFLOWHISTORY{...}%
Parameter | Meaning | Default |
---|---|---|
format |
Format of each transition | $state -- $date |
header |
Header before results | |
footer |
Footer after results | |
separator |
Separator between results | <br /> |
include |
Perl regular expression matching states to include | |
exclude |
Perl regular expression matching states to exclude |
format
, header
, footer
and separator
parameters provide the control necessary to make the history look nice
when it is viewed.
In this example the history is formatted as a simple table:
%WORKFLOWHISTORY{format="| $state | $author | $date |" separator="$n"}%The standard FormatTokens are supported, as well as the following special tokens:
Token | Expands to |
---|---|
$author |
Who triggered the transition to this state (also $user and $wikiusername ) |
$comment |
Comment accompanying the record |
$date |
Date/time of the transition in the default format (you can format your own date using the same formatting tokens as used by %GMTIME% ) |
$index |
1-based number of this result |
$name |
Version at the transition (also $rev ) |
$state |
The state of the topic after the recorded event occurred |
%WORKFLOWLAST{...}%
Parameter | Meaning | Default |
---|---|---|
"State" |
Name of the state | |
format |
Format | $rev: $state $author $date |
format
is the same as that used for %WORKFLOWHISTORY%
.
%WORKFLOWSTATE%
%WORKFLOWSTATEMESSAGE%
%EDITTOPIC%
with %WORKFLOWEDITTOPIC%
in your skin templates, then the Edit link is crossed out when the user is not allowed to edit the page in a state.
Similarly, you can use %WORKFLOWATTACHTOPIC%
in your skin templates to cross out the Attach link.
META
macro to pick up values for these fields from the form
attached to the viewed topic:
State table
| *State* | *Allow CHANGE* | *Message* | | WAITINGFORAPPROVAL | %META{"formfield" name="MayModify"}% | This document is waiting for approval |Transition Table
| *State* | *Action* | *Next State* | *Allowed* | | WAITINGFORAPPROVAL | approve | %META{"formfield" name="ApprovedState"}% | %META{"formfield" name="MayApprove"}% |
See #AccessControl for more information.
You can also define other macros starting withWORKFLOW
in the workflow
description topic. These will be expanded to their defined values in any
topic that uses the workflow. For example: WORKFLOWNOTICE
in any topic that uses the workflow.
%SEARCH{"META:WORKFLOW.name='APPROVED'" type="query"}%
| *State* | *Allow CHANGE* | *Allow VIEW* | | UNDERREVISION | EngineeringGroup | |When a topic is transitioned to this state, all other topic-level permissions will automatically be removed, and the permissions:
nobody
can be used to restrict access for everyone (except admins).
not(WikiGuest)
.
not(LASTUSER_{State})
.
DENYTOPIC
preferences in metadata. Access
controls set in these ways may prevent the plugin from working
correctly.
tools/workflowremind
perl script, which is run on the server - either manually, or using a cron
job. To find out how this is used, change to the tools
directory on the server and perl workflowremind
with no parameters.
The mail sent by this script is formatted using skin template called mailworkflowremind
. You can override this by providing a template topic called WorkflowRemindMailTemplate
in the web where the transitioned topic resides.
The following identifiers are expanded in the template:
EMAILTO |
Comma-separated list of email addressess |
TRANSITION |
Name of the transition |
TARGET_STATE |
State being transitioned to |
STUCK |
How long the topic has been stuck in that state |
If there is no WORKFLOW preference setting, then the form field "Workflow" is used for the workflow name. Note that because the form can change when a transition happens, the so can the workflow. Using this technique, it is possible for a topic to switch between workflows as the result of a transition.
workflowstrings.tmpl
- contains translateable definitions for all error messages and inline controls,
mailworkflowtransition.tmpl
is the template for the email sent for a transition * mailworkflowmither.tmpl
is the template used when re-mailing a transition notification, * workflowedit.tmpl
is the template used for editing during a transition (i.e. when a new form is attached)
WORKFLOWTRANSITIONCSSCLASS
can be set to the names of one or more CSS
classes that are used to style buttons, such as the transition and fork buttons.
More complex customisations can be achieved through use of skins - see
SkinTemplates for more information.
META:WORKFLOW
- unique name
- current state of this topic
LAST(TIME|USER|VERSION|COMMENT)
- deprecated, replaced with WORKFLOWHISTORY
META:WORKFLOWHISTORY
- may be many name
- revision identifier
author
- who did the transition/fork
date
- time the transition/fork happened (epoch secs)
state
- state transitioned into
comment
- comment accompanying the transition
Forks are recorded in both the forked topic, and the topic created by the fork.
In the topic that was forked from,forkto
- comma-separated list of web.topic generted by the fork
forkfrom
- web.topic that the topic is forked from
rev
- the revision of the forkfrom
topic after the fork was done
WORKFLOWDEBUG
preference, either in the workflow description topic or in
an individual controlled topic, to get extra information about the macros
being expanded when a controlled topic is viewed. Information is embedded
into the topic in HTML comments (use 'view source' in the browser to see them)
and, if {Plugins}{WorkflowPlugin}{Debug}
is enabled in configure, additional
messages (mostly related to access control) are written to the debug log (requires administrator access).
This version of the plugin is intended for use with Foswiki 2.0 and later. If you are running an older Foswiki, do not install it!
You do not need to install anything in the browser to use this extension. The following instructions are for the administrator who installs the extension on the server.
Open configure, and open the "Extensions" section. "Extensions Operation and Maintenance" Tab -> "Install, Update or Remove extensions" Tab. Click the "Search for Extensions" button. Enter part of the extension name or description and press search. Select the desired extension(s) and click install. If an extension is already installed, it will not show up in the search results. You can also install from the shell by running the extension installer as the web server user: (Be sure to run as the webserver user, not as root!)cd /path/to/foswiki perl tools/extension_installer <NameOfExtension> installIf you have any problems, or if the extension isn't available in
configure
, then you can still install manually from the command-line. See https://foswiki.org/Support/ManuallyInstallingExtensions for more help.
Note: The script convert.pl.txt
will convert topics written for the ApprovalPlugin to the WorkflowPlugin. The script takes a topic at the standard input and outputs the converted topic on standard output. Rename the file from convert.pl.txt
to convert.pl
.
Look at the examples in the Sandbox web.
Note: For strict access control, the plugin should know who is looking at the controlled document/topic at all times. To enable this, you may want to set up the wiki in such way that users have to log-in even if they just display a topic.$n
is interpreted as \n, not <br>, in line with the standard format tokens. If you want a <br> in the format string, then enter it as <br> or $percntBR$percnt.
Author | Thomas Hartkens, Foswiki:Main.ThomasWeigert, Foswiki:Main.CrawfordCurrie |
Version | 1.17 |
Release | 1 Aug 2017 |
Repository | https://github.com/foswiki/WorkFlowPlugin |
Home | http://foswiki.org/Extensions/WorkflowPlugin |
Support | http://foswiki.org/Support/WorkflowPlugin |