Share via


Dynamic Update from Workflow Sample

Download sample

This sample demonstrates how to dynamically update a workflow instance when it is running from inside the workflow (code-beside).

The workflow receives a purchase order request of some amount. The workflow automatically approves the purchase order when the amount is less than $1000. When the amount is greater than $1000, a purchase order approval is required. This is achieved by dynamically adding an InvokeWorkflowActivity activity from the workflow in its code-beside. Invoking another workflow enables you to encapsulate approval request logic in a workflow. However, approval logic can also be performed inline if you want.

When you build and run the sample, your output will appear similar to the following:

Output from Dynamic Update sample

Database Configuration

The SQL Server services that are installed by Windows Workflow Foundation use Microsoft SQL Server to store information. You can use Microsoft SQL Server 2005 Express, SQL Server 2000 or later versions, or SQL Server 2000 Desktop Engine (MSDE) for these tasks.

Windows Workflow Foundation Setup does not install the databasesthat these services require; however, Setup installs the SQL scripts for creating and configuring the databases for these services.

The following steps describe how to create and configure the databases that are used by services in this sample.

To create and configure the SQL Server database

  1. Using Microsoft SQL Server 2005 Express, SQL Server 2000 or later versions, or SQL Server 2000 Desktop Engine (MSDE), create a new database named SqlPersistenceService by using the SQL query statement:

    CREATE DATABASE SqlPersistenceService
    

Note

When using both the SqlTrackingService and the SqlWorkflowPersistenceService in a workflow application, it is recommended to use a single database for both persistence and tracking.

  1. In the SQL Query Analyzer workspace, select the database that you created in step 1 in the list of available databases.

  2. On the File menu, click Open, and open the SQL script %WINDIR%\Microsoft.NET\Framework\v3.0\Windows Workflow Foundation\SQL\<language>\SqlPersistenceService_Schema.

  3. Execute the query by clicking Execute or by pressing F5 to create the SQL Persistence Service tables.

  4. On the File menu, click Open, and open the SQL script %WINDIR%\Microsoft.NET\Framework\v3.0\Windows Workflow Foundation\SQL\<language>\SqlPersistenceService_Logic.

  5. Execute the query by clicking Execute or by pressing F5 to create the SQL Persistence Service stored procedures.

To build the sample

  1. Download the sample by clicking Download Sample.

    This extracts the sample project to your local hard disk.

  2. Click Start, point to Programs, point to Microsoft Windows SDK, and then click CMD Shell.

  3. Go to the source directory of the sample.

  4. At the command prompt, type MSBUILD <Solution file name>.

To run the sample

  • In the SDK Command Prompt window, run the .exe file in the DynamicUpdateFromWorkflow\bin\debug folder (or the DynamicUpdateFromWorkflow \bin folder for the VB version of the sample), which is located below the main folder for the sample.

See Also

Reference

WorkflowChanges
ApplyWorkflowChanges

Other Resources

Using Dynamic Updates in Workflows
Applying Dynamic Updates to Workflows
Dynamic Update Samples
Dynamic Update from Host Sample
Dynamic Updates to Rule Conditions

© 2007 Microsoft Corporation. All rights reserved.