- Just add a new "Activity Library" project to your solution.
- Create an activity in the library that contains the common part.
- Add a reference to the Activity Library project.
- Build all in release.
- Drop the common activity into your workflows.
How to reuse parts of Windows Workflows?
-
26-06-2022 - |
Question
I have 2 different WF workflows, which both use an identical piece of logic.
Currently that part is copypasted from one workflow to another.
How can I use a part of a workflow in two different workflows without duplicating it?
Basically, I want to have one "library" workflow, which is used by the 2 "real" workflows.
Solution
OTHER TIPS
You could make a new type of activity which is able to start a workflow definition. So you end up with a workflow definition A, workflow definition B. And within this definitions you can place your custom activity which can execute a new workflow definition C. So A and B points to C. Workflow definition C can be defined as a child workflow of A and B.
I think this link is a good starting point. http://wf.codeplex.com/wikipage?title=How%20do%20I%20invoke%20a%20Child%20Workflow%3f&referringTitle=Microsoft.Activities%20Overview
You can also just make a workflow with the common part and use LoadAndInvokeWorkflow activity to execute it in another workflow.