Item1828: Conditional transitions for WorkflowPlugin
Priority: Enhancement
Current State: Closed
Released In:
Target Release: n/a
I coded another very small enhancement to the
WorkflowPlugin. It allows me to do:
| MYSTATE | conditional action | %IF{"QuantityAccepted" then="MYNEXTSTATE" else=""}%| engineering, managers | | |
such that the allowed next state list can make decisions based on the topic under control. The code change is actually very simple. I've attached the diff to Workflow.pm (
Workflow.pm.diff) (it is generated against TWiki version of the
WorkflowPlugin so it will have to be applied manually)
I needed to modify getActions() and getNextState()
Summary of changes are:
- Expand macros on the NextState column then
- only add transition to list of available actions if it is not empty.
--
DeanSpicer - 14 Jul 2009
This took a while to incorporate because there was no documentation, so I had to write some. Can you please check it, make sure I haven't made any obvious boo-boos? Here's what i wrote:
Content-sensitive workflows
Advanced Flows can be made sensitive to the content of the controlled
topics. The 'Allow Edit' column in the state table, and the 'Next State'
and 'Allowed' columns in the transition table, support the use of macros
which are expanded
when the topic is viewed. For example, you can use the
META
macro to pick up values for these fields from the form attached to the topic:
State table
| *State* | *Allow Edit* | *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"}% |
You can also define other macros starting with
WORKFLOW
in the workflow
description topic. These will be expanded to their defined values in any
topic that uses the workflow. For example:
- Set WORKFLOWNOTICE = This topic is under document control.
will define
WORKFLOWNOTICE
in any topic that uses the workflow.
--
CrawfordCurrie - 02 Sep 2009