Skip to main content
Expert
July 20, 2026
Question

ExecuteParseAndTransform randomly failing

  • July 20, 2026
  • 3 replies
  • 61 views

Hi all, I am working on the Extensibility Rule to automate the Import/Validate/Load/etc. steps of a workflow, so that when the rule is called from a data management step it executes all workflow steps for a given workflow.

The first step of the workflow is a Workspace containing a dashboard, and the second is an Import step (we are using a direct connection).

The rule works generally fine, but the Import step randomly throws the following error:

"Cannot execute step because the prior workflow step is not completed...Source code: line 0, method ParseAndTransform"

This happens maybe less than 10% of the times, but it is annoying because I cannot understand the reason for it, since the Workspace step which precedes the Import step should always be completed since it is completed by the Extensibility rule itself.

These is an extract from the rule of how I complete and immediately after process the Import:

Dim CompleteWorkspaceWFInfo As WorkflowInfo = BRApi.Workflow.Status.SetWorkflowStatus(si, wfUnitClusterPK, StepClassificationTypes.Workspace, WorkflowStatusTypes.Completed, statusMessage, errorMessage, updateReason, Guid.Empty)

Dim Load As LoadTransformProcessInfo = BRApi.Import.Process.ExecuteParseAndTransform(si, wfUnitClusterPk, String.Empty, Nothing, TransformLoadMethodTypes.Replace, SourceDataOriginTypes.FromDirectConnection, True)

Thinking it was maybe a timing issue of the ExecuteParseAndTransform sometime starting before OneStream had time to completely refresh the state of the Workspace step, I tried to add the following code between the 2 lines above:

' Get the current workspace step
Dim workspaceStep As StepInfo = BRApi.Workflow.Status.GetWorkflowStatus(si, wfUnitClusterPK, False).GetStep(StepClassificationTypes.Workspace)
' Loop a maximum of 3 seconds
For i As Integer = 0 To 2
' Check if the step has completed or encountered an error
If workspaceStep.Status.Equals(WorkFlowStatusTypes.Completed) Or workspaceStep.Status.Equals(WorkFlowStatusTypes.HasError) Then
Exit For
End If
'Introduce a delay of 1 seconds asynchronously
Await Task.Delay(1000)
Next

However, this has not solved the issue, and the Await seems not to be triggered even when the ParseAndTransform throws the “prior workflow step is not completed” error. Does anyone have any idea of where the issue could reside or have seen something similar?

Thank you

3 replies

RobbSalzmann
Advisor
Advisor
July 20, 2026

The Await never fires  mainly because you cannot run Await in method not marked Async and also because the loop checks the Workspace step's status which your code set to Completed one line earlier so Exit For triggers on the first pass before reaching it. You want to check whether the import step sees its dependency satisfied (WorkflowInfo.StepCanBeExecuted), not confirm your own write.

The intermittent failure is probably a state-propagation lag: the completion write hasn't reached the reader the import uses, and a poll from your own context can't reliably see that.

RobbSalzmann
Advisor
Advisor
July 20, 2026

Just a bit more explanation, Await Task.Delay(1000) must run in a sub or function marked as Async. 

What you need to do is synchronous not asynchronous.  Asyc is fire and forget, the process is kicked off and the code that kicked it off keeps running on it’s own thread.  This is probably what is causing the intermittent error.  

Use T h r e a d.S l e e p instead(spaced out on purpose in order to get the code to post in this forum):

' Complete the Workspace step.
Dim workspaceCompleteInfo As WorkflowInfo = BRApi.Workflow.Status.SetWorkflowStatus(si, wfUnitClusterPk, StepClassificationTypes.Workspace, WorkflowStatusTypes.Completed, statusMessage, errorMessage, updateReason, Guid.Empty)

' Poll the load step before invoking it,
' to check reflects current server state.
' Use StepCanBeExecuted to test if the the step is ready to start
Dim loadStepCanRun As Boolean = False
Dim hasLoadStep As Boolean = False

For attempt As Integer = 1 To 4
Dim currentInfo As WorkflowInfo = BRApi.Workflow.Status.GetWorkflowStatus(si, wfUnitClusterPk, False)

loadStepCanRun = currentInfo.StepCanBeExecuted(StepClassificationTypes.DataLoadTransform, hasLoadStep)

If loadStepCanRun Then Exit For

T h r e a d.S l e e p(2000)
Next

' Run parse and transform once, then judge the result object rather than
' assuming a returned result means success.
Dim load As LoadTransformProcessInfo = BRApi.Import.Process.ExecuteParseAndTransform(si, wfUnitClusterPk, String.Empty, Nothing, TransformLoadMethodTypes.Replace, SourceDataOriginTypes.FromDirectConnection, True)

If load.HasError Then
Throw ErrorHandler.LogWrite(si, New XFException(si, $"Parse and transform failed. {load.ErrorMessage}"))
End If

 

AndreaFAuthor
Expert
July 20, 2026

Hi ​@RobbSalzmann ,

my method was set to Async to enable the use of Await, but I was simply trying to introduce a delay and wasn't familiar with the available options. I'll switch to Thread.Sleep as you suggested.

I've updated my code to incorporate your example, but I'm now facing an issue: loadStepCanRun always returns False, regardless of how many attempts are there in the For statement or how long I set the sleep to be. Do you have any ideas why this might be happening?

The ExecuteParseAndTransform command after the loop works fine. This suggests the step can actually execute even though StepCanBeExecuted returns False beforehand.  Any insight would be appreciated!