-
I am interested in the ability of initiating a workflow at a 'downstream' Step (a Step other than the first). This would greatly reduce the number of workflow definitions needed to support some related workflow scenarios. Has this feature/capability been considered, and ruled out/in for any reason? I'd be happy to try and contribute a PR if this was straight forward development. Looking at the code I see a method in ExecutionPointerFactory called
As an aside, thanks for your efforts building, sharing, and maintaining in this library! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
For the benefit of others, we finally achieved this via WorkflowStepMiddleware. The following code snippet demonstrates the fundamental part of this approach: // ----------------------------------------------------
// Inside IWorkflowStepMiddleware.HandleAsync
// ----------------------------------------------------
// Retrieve the workflow definition using the current workflow's definition ID and version.
var definition = _workflowRegistry.GetDefinition(context.Workflow.WorkflowDefinitionId, context.Workflow.Version);
// Find the designated start step within the workflow definition based on an external identifier.
var startStep = definition.Steps.Find(x => x.ExternalId == workflowTargetStartStep.StartStepId);
// Check if the current step's ID is less than the start step's ID, which indicates that
// the current step should be skipped and the workflow should proceed to the start step.
if (context.Step.Id < startStep.Id)
{
// Return the 'Next' execution result to move the workflow execution forward.
return Task.FromResult(ExecutionResult.Next());
} public interface IWorkflowTargetStartStep
{
string? StartStepId { get; set; }
} |
Beta Was this translation helpful? Give feedback.
For the benefit of others, we finally achieved this via WorkflowStepMiddleware. The following code snippet demonstrates the fundamental part of this approach: