locked
Adding a workflow activity at runtime after workflow instance is created RRS feed

  • Question

  • Hi, 

    I am planning to use WF4 in our application which does work in  simple workflows.  Workflows that I am working on is pretty simple too.  

    Follow are the activities defined in XAML designer workflow

    A -> - B-> C-> D

    Workflow is initiated with above sequence. but here it gets tricky.

    I wanted to add a new activity 'X' at runtime in the middle of activities after workflow instance is created (using persistence). So workflow initiated with the same sequence 

    A -> B -> C - > D 

    but after executing activity 'A' I have to change it to

    A -> B -> X -> C - > D

    I have my own database side by side with WF persistance tables to maintain the data related to activity, user, state and logs.

    Newer workflow should work as is (A -> - B-> C-> D)

    I have heard of dynamic activity in WF4 but don't know how my solution can be achieved. 

    Thank you in advance 

    - Faraz


    faraz

    Thursday, November 7, 2013 5:16 AM

Answers

  • Hi farazfaheem

    If you want to learn DynamicActivity Creation to do that, there are two different ways to create an activity at runtime using the DynamicActivity activity.

    An activity is created at runtime with a body that contains a Sequence activity that contains ForEach and Assign activities. An input list of integers is passed into the activity and set as a property. The ForEach activity then iterates over the list of values and accumulates it. In the Assign activity, the average value is calculated by dividing the accumulator by the number of elements in the list and assign it to the average.

    Please take a look at this example, and make some modification according to your requirements.

    # DynamicActivity Creation http://msdn.microsoft.com/en-us/library/dd807392(v=vs.110).aspx

    Regards


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Angie Xu Tuesday, November 19, 2013 1:37 AM
    Monday, November 11, 2013 2:21 AM