TechBubbles Microsoft Technology BLOG

Using If/Else activity in Workflow Foundation


In this post I will explain how to utilize the IF\Else activity and a declarative condition in the workflow to perform the conditional processing.

This workflow evaluates the order by taking the order value and if the order value  < $1000 then it will approved by Manager other wise it requires vice president  approval.

1. Create a new workflow project by selecting File->New->Project menu command visual studio displays the New Project dialogue window.


2. Select the Empty Workflow Project template from the dialogue box and say ok.


3. Add the new item to the empty workflow project and select the Sequential Workflow (with code separation) template from the above dialogue box.

4. Start the workflow by writing the following code in Main program.cs file.


In above code we have started the workflow runtime and loaded the workflow type that we are going to design in the next step.

Notice that we are also passing the OrderValue as the parameter to the workflow.

5. Add the IF/ELSE activity to the workflow designer from the toolbox.



6. Add the condition to the ifElseBranch1 by selecting the ConditioName from the properties window.



7. Similarly Add the condition to the ifElseBranch2 by selecting the condition name from the properties window.


8. Add the code activities below the both ifElseBranch1 and ifElseBranch2 branches and attach the event handlers to the ExecuteCode property.


9.  The code besides file of the workflow will look like


10. You can attach the ManagerApprovalHandler to one branch and VPApprovalHandler to another branch by selecting the code activities and assign the value to the Executecode property.

11.  You will see the following output after executing the application



We discussed about using the If/Else activity in workflow and evaluating the conditions using the activity. In the next post we discuss about other important activities in the workflow.

About the author

Kalyan Bandarupalli

My name is kalyan, I am a software architect and builds the applications using Microsoft .NET technologies. Here I am trying to share what I feel and what I think with whoever comes along wandering to Internet home of mine.I hope that this page and its contents will speak for me and that is the reason I am not going to say anything specially about my self here.


  • Hai,
    I am new for windows workflow foundation. It is very useful for me to create basic workflow by using if else.
    could you provide some site to learn more about wwf.


  • Hi Techbuddies,

    This is a wonderful post and i loved reading it. I am new to workflow and started reading this post for creating the If-Else based conditional workflow test application and i could able to make that and created server other applications too. Thanks! you guys did a amazing job!

    Carry on! Cheers!

TechBubbles Microsoft Technology BLOG

Follow me


Tag Cloud