Branching workflow is a common requirement, and is quite easy to achieve
using the basic On Success or On Failure constraints available through
the designer. However branches go in different directions and do not
meet up again.
The term path is used here to indicate that whilst the workflow branches
in one direction, it will also converge at a given point. This is not
easy to achieve using the designer, as by default all workflow
constraints pointing to a single task must all be satisfied. This
example shows how we can simulate OR logic as oppose to the default AND
logic normally available.
The image below shows our sample package. We have a Start task
which is where we make the decision as to which of the two paths we wish
to follow. The SetupPath task will implement our decision. Next
we have our two paths, tasks A, B and C or tasks
X, Y and Z. Finally the End task will
execute regardless of which path we took to get there.
For the demonstration package our first task cotains the following code. This is used to assign our
path decision to global variable:
' 218 (Start)
Option Explicit
Function Main()
Const vbYes = 6
Const vbYesNo = 4
Dim sMsg, lResult
sMsg = "Please choose a path:" & vbCrLf & _
"Yes - Execute ABC path" & vbCrLf & _
"No - Execute XYZ path"
lResult = MsgBox(sMsg, vbYesNo)
If lResult = vbYes Then
DTSGlobalVariables("ExecuteTruePath").Value = True
Else
DTSGlobalVariables("ExecuteTruePath").Value = False
End If
Main = DTSTaskExecResult_Success
End Function