2
Our second task is the task. This is the one to be executed or not.
The decision is implemented via an ActiveX Workflow
script. (Right-Click the task, select Workflow then Workflow Properties.
On the options tab check "Use ActiveX script", and click Properties).
This script does two key things based on the value of SkipTask.
By using the DTSStepScriptResult constants we determine whether of not
to execute this task.
The other purpose is to change the workflow following this
task. This ensures that what appears to be a normal On Success
constraint will still allow the final task to execute, when this task
does not. If this task is to be executed we do the reverse,
there by reinstating the On Success nature of the constraint.
' Pkg 214 (SkipTask)
Option Explicit
Function Main()
Dim oPkg, oStep
' Get the FinalTask Step
Set oPkg = DTSGlobalVariables.Parent
Set oStep = oPkg.Steps("DTSStep_DTSActiveScriptTask_3")
If DTSGlobalVariables("SkipTask").Value Then
' Update the following task's precedence constraint
' - Execution status of inactive
oStep.PrecedenceConstraints(1).PrecedenceBasis = _
DTSStepPrecedenceBasis_ExecStatus
oStep.PrecedenceConstraints(1).Value = _
DTSStepExecStat_Inactive
Main = DTSStepScriptResult_DontExecuteTask
Else
' Update the following task's precedence constraint
' - Execution result of success
oStep.PrecedenceConstraints(1).PrecedenceBasis = _
DTSStepPrecedenceBasis_ExecResult
oStep.PrecedenceConstraints(1).Value = _
DTSStepExecResult_Success
Main = DTSStepScriptResult_ExecuteTask
End If
Set oStep = Nothing
End Function
The task itself has some simple code for this example.
' Pkg 214 (SkipTask - 2)
Option Explicit
Function Main()
MsgBox "This is THE task!"
Main = DTSTaskExecResult_Success
End Function