Using Elsa Workflow, how can I inherit CorrelationId in sub workflow using IWorkflowBuilder?

333 views Asked by At

Ciao,

I'm writing some workflows using Elsa Workflow .NET library. I'm using last stable version (v. 2.10.2.2).

I've wrote two workflows:

public class MyWorkflow : IWorkflow
{
    public void Build(IWorkflowBuilder builder)
    {
        builder.WorkflowBuilder
            .HttpEndpoint(setup => setup.WithPath("myworkflow"))
            .RunWorkflow<OtherWorkflow>(RunWorkflowMode.Blocking)
            .Finish();
    }
}

public class OtherWorkflow : IWorkflow
{
    public void Build(IWorkflowBuilder builder)
    {
        builder.WorkflowBuilder
            .HttpEndpoint(setup => setup.WithPath("otherworkflow"))
            .Finish();
    }
}

And I've create a new instance of MyWorkflow with this HTTP request:

curl --location 'https://localhost:7236/myworkflow' \
--header 'X-Correlation-Id: document1.docx' 

The sub-workflow OtherWorkflow has a new CorrelationId, like picture below:

Workflow picture

I need that all sub-workflows inherit CorrelationId of parent, because I will have a lot of sub-workflows that needs to be correlated with it's parent.

How can I reach my goal programmatically?

Thanks

1

There are 1 answers

0
Mubin On

In case if anyone is still looking an answer for this, it can be done by providing correlationId as the value in Correlation Id field in Advanced tab of RunWorkflow activity.

Reference Screenshot