Share via


Designing Workflow Processes for SQL Server

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

To design a workflow process for a table in your workflow project, first analyze the steps that each item must follow and any constraints that control the process. For each step, you add an associated state to the workflow. Keep in mind that script can be added to each state and transition that validates conditions, controls the process, triggers other events, and so on.

When you selected a table for workflow, the Workflow Designer added Item Created and Item Deleted shapes to the design surface automatically. The Item Created shape appears in the workflow process diagram as the starting block, and the Item Deleted shape appears as the ending block. Between these points, you now add states, events, and transitions to design the workflow process.

To design a workflow process

  1. Drag the State shape from the Workflow Toolbox to the design surface.

  2. Change the caption on the state to a name that identifies the state clearly, such as Active or Opened.

  3. Click the Transition shape in the Workflow Toolbox, and then drag from the Item Created shape to the state you added. A transition arrow appears that points from the first object to the second.

  4. Add the remaining states and transitions to complete your workflow diagram.

    If you want to make it possible for a record to be edited without changing states, click the Transition Within shape in the Workflow toolbox, and then click the appropriate state.

  5. Add any desired script to the workflow process. Three script blocks are called when an item moves from one state to the next: previousstate_OnExit, OnChange, and nextstate_OnEnter.

    For example, you might want to trigger the sending of e-mail to the person who opened an issue when the ResolvedState_OnEnter script block is called.

  6. Test your workflow.

See Also

Understanding the Workflow Process for SQL Server | Adding Workflow Processes to Databases | Controlling Permissions for Events | Initiating Workflow for a Record | Testing Workflow Processes for SQL Server | Scripting Workflow