Export (0) Print
Expand All

How to: Create a Workflow for Workflow Manager 1.0

Updated: May 15, 2013

In this step of the Workflow Manager 1.0 Getting Started Tutorial, a workflow is created that uses the GetProducts activity to return a collection of products. The workflow iterates through the collection and extracts the product name for each returned product, adds it to a list, and sets a user status containing the name of the product. This status is read and displayed by the workflow client application, which is created in a subsequent tutorial step. After all products have been read, the workflow sets a user status containing the list of product names, and completes.

noteNote
To watch a video walkthrough, or download the starter files and a completed version of the tutorial, see Workflow Manager 1.0 - Getting Started Tutorial.

In this Tutorial Step

Create the Workflow

  1. Open the solution from the previous step in the tutorial, How to: Create a Custom Activity for Workflow Manager 1.0, if it is not already open in Visual Studio 2012.

  2. Right-click GetProductsActivities in Solution Explorer and choose Add, New Item.

  3. In the Installed, Visual C# Items node, select Workflow. Select Activity from the Workflow list.

  4. Type GetProductsWorkflow into the Name box and then click Add.

  5. Double-click GetProductsWorkflow.xaml in Solution Explorer to display it in the designer if it is not already displayed.

  6. Drag a Sequence activity from the Control Flow section of the Toolbox and drop it onto the Drop activity here label of the workflow designer.

Create the Arguments and Variables

  1. Click Arguments in the lower-left side of the activity designer to display the Arguments pane.

  2. Click Create Argument.

  3. Type SearchKeyword into the Name box, select In from the Direction drop-down list, and select String from the Argument type drop-down list.

  4. Click Arguments in the lower-left side of the activity designer to close the Arguments pane.

  5. Click Variables in the lower-left side of the activity designer to display the Variables pane.

  6. Click Create Variable.

    TipTip
    If Create Variable is not displayed, click the Sequence activity in the workflow designer to select it.

  7. Type ProductsData into the Name box, and select Browse for Types from the Variable type drop-down list

  8. Type DynamicValue in the Type Name box, select DynamicValue from the results list, and click OK.

  9. Click Create Variable.

  10. Type Count into the Name box, and select Int32 from the Variable type drop-down list.

  11. Click Create Variable.

  12. Type ProductsList into the Name box, and select String from the Variable type drop-down list.

  13. Click Variables in the lower-left side of the workflow designer to close the Variables pane.

Add the Workflow Activities

  1. Drag a GetProducts activity from the GetProductsActivities section of the Toolbox and drop it in the Sequence activity, and configure the following properties.

     

    Property Value

    ProductsData

    ProductsData

    SearchKeyword

    SearchKeyword

  2. Drag a CountDynamicValueItems activity from the DynamicValue section of the Toolbox and drop it on the Sequence activity so that it follows the GetProducts activity, and configure the following property values.

     

    Property Value

    Result

    Count

    Source

    ProductsData

  3. Drag a SetUserStatus from the Runtime section of the Toolbox and drop it so that it follows the newly added CountDynamicValueItems activity, and specify the following expression for the Description property.

    "Products: " + Count
    
  4. Drag a Delay activity from the Primitives section of the Toolbox and drop it so that it follows the newly added SetUserStatus activity, and specify the following expression for the Duration property. The delay allows the workflow client to retrieve the status before the workflow sets the next status, and is added for the purposes of this tutorial. In a production application techniques such as using messaging activities or writing records to a database would be used to transfer information.

    TimeSpan.FromSeconds(1)
    
  5. Drag a While activity from the Control Flow section of the Toolbox and drop it so that it follows the newly added SetUserStatus activity.

  6. Click Variables in the lower-left side of the activity designer to display the Variables pane.

  7. Click Create Variable.

  8. Type Items into the Name box, select Int32 from the Variable type drop-down list, ensure that While is selected in the Scope drop-down list, and type 0 in the Default box.

  9. Click Create Variable.

  10. Type ProductName into the Name box, select String from the Variable type drop-down list, and ensure that While is selected in the Scope drop-down list.

  11. Click Variables in the lower-left side of the activity designer to close the Variables pane.

  12. Type the following expression in the Condition box of the While activity.

    Items < Count
    
  13. Drag a GetDynamicValueProperty<T> activity from the DynamicValue section of the Toolbox and drop it on the Body of the While activity.

    In the Select Types window that appears once the activity is dropped, select String from the drop-down list, and click OK.

  14. Click the GetDynamicValueProperty<T> activity in the workflow designer to select it, and configure the following properties.

     

    Property Value

    DisplayName

    GetProductName

    PropertyName

    "(" + Items + ")/ProductName"

    Result

    ProductName

    Source

    ProductsData

  15. Drag a SetUserStatus from the Runtime section of the Toolbox and drop it on the While activity so that it follows the newly added GetDynamicValueProperty<T> activity, and specify the following expression for the Description property.

    "Product: " + ProductName
    
    noteNote
    Note that when the SetUserStatus is dropped, an enclosing Sequence activity is added that contains both the GetDynamicValueProperty<T> activity and the SetUserStatus activity.

  16. Drag a Delay activity from the Primitives section of the Toolbox and drop it so that it follows the newly added SetUserStatus activity, and specify the following expression for the Duration property. The delay allows the workflow client to retrieve the status before the workflow sets the next status, and is added for the purposes of this tutorial.

    TimeSpan.FromSeconds(1)
    
  17. Drag an Assign activity from the Primitives section of the Toolbox and drop it so that it follows the newly added Delay activity, and configure the following properties.

     

    Property Value

    To

    Items

    Value

    Items + 1

  18. Drag a second Assign activity from the Primitives section of the Toolbox and drop it so that it follows the first Assign activity, and configure the following properties.

     

    Property Value

    To

    ProductsList

    Value

    ProductsList + ProductName + "\n"

  19. Drag a SetUserStatus from the Runtime section of the Toolbox and drop it so that it follows the While activity as the last activity in the outer Sequence, and specify the following expression for the Description property.

    "Products List:\n" + ProductsList
    
    Note that the user status is limited to 255 characters, and any characters beyond 255 are truncated.

  20. Press Ctrl+Shift+B to build the solution.

    To see an example of the completed workflow, and a video walkthrough of this tutorial step, see Workflow Manager 1.0 - Getting Started Tutorial

For instructions on how to create a publish and run the workflow, see the next step in the tutorial, How to: Publish and Run a Workflow for Workflow Manager 1.0.

See Also


Workflow Manager 1.0 MSDN Community Forum


Build Date:

2014-01-17

Community Additions

ADD
Show:
© 2014 Microsoft