Workflow calculator query
Question
It is possible to use WFCALC_
stored procedures to trigger automatic actions in workflows. These stored procedures use the @strOutput output parameter.
How can we use WFCALC_
procedures and what is the usage of the output parameter?
And if we use it, how can we check the status (success/failure) of stored procedure inside the workflow
Answer
WFCALC
procedures can be used in logic execution steps. strOutput value is stored in StoredProcedureResult field of WorkflowProcessStepInstance table. This result can then be used in a split decision procedure in the process.
For example, if a WFCALC
returns “1” in a logic execution step, a WFSPLIT
procedure can evaluate this result in the same step and redirect the workflow based on the output. The pseudo code for the WFSPLIT
would be as follows:
SELECT @strResultOfWFCALC=StoredProcedureResult FROM WorkflowProcessStepInstance WITH (NOLOCK) WHERE ProcessStepInstanceId=@StepId
IF @strResultOfWFCALC = '1' then
begin
set @strOutput = 'Approved' --this is the strOutput of WFSPLIT
end
If WFCALC
fails due to an SQL error then the workflow may halt. In that case the workflow log needs to be checked for the error message.