Search code examples
workflow.net-4.5workflow-foundation-4workflow-foundation

How to get the Result from previous activity?


I am new to WF 4.5.

The "GenerateResult" activity will generate a string in the Result property.

I want to assign the Result to the varExternal in the following Assign activity.

How to?

enter image description here

The GeneratedResult activity is defined as below.

public sealed class GenerateResult<TResult> : NativeActivity<TResult>
{
    protected override void Execute(NativeActivityContext context)
    {
        this.Result.Set(context, "Hello, world!");
    }
}

Solution

  • Just like you'd do it when programming. You have to hold the result within a variable, then reference that variable elsewhere.

    I'm assuming you want to use the result in the WriteLine activity, so you would create a variable within the workflow (look at the bottom of the designer), bind it to the Result property of your GenerateResult activity (it's in the Property grid, so right-click and hit Properties). Then you can reference that variable in the WriteLine activity.