With Microsoft Office SharePoint Designer 2007, you can design workflows that add application logic to your site or application without having to write custom code. Using the Workflow Designer, you create rules that associate conditions and actions with items in Microsoft SharePoint lists and libraries, so that changes to items in lists or libraries trigger actions in the workflow.
For example, you can design workflows to automate business processes in your enterprise — such as document review, approval, and archiving, among others. Or you can quickly create workflows just to take care of routine processes on your team site, such as sending notifications or creating tasks.
This article helps get you started by explaining some key design considerations and providing a basic procedure. In the last section, you can find links to complete workflow examples.
To learn more about workflows, seeIntroduction to workflows.
Important To create a workflow, your site must be located on a server running Microsoft Windows SharePoint Services 3.0 or Microsoft Office SharePoint Server 2007.
In this articleHow does a workflow evaluate steps?Before you beginDesign the workflowSuggested next stepsHow does a workflow evaluate steps?
You can think of a step in a workflow simply as a page in the Workflow Designer that groups a set of related conditions and actions. All the conditions and actions on that page are evaluated and processed at one time. So a workflow is started (either manually or automatically), and for each step it evaluates any conditions that have been created, and then performs the actions that you choose in the Workflow Designer. One step in a workflow can perform any number of actions, from sending an e-mail message to creating, copying, moving, or deleting a list item.
When you create a workflow with many steps, a key consideration is how you group the actions and conditions in each step of the workflow. The rules in one step are processed to conclusion before going on to the next step, so you want to group in the same step any rules necessary to effect the specific action or actions that you want.
Also, you must design the workflow so that each step follows logically from the previous step. For example, if the workflow depends on a response from a workflow participant, the workflow should have the necessary conditions and actions to accommodate all possible responses.
When you design a workflow, it is important to understand how a workflow evaluates each step. The following statements are all true:If a step contains only actions and no conditions, the workflow always performs those actions.If a step has conditional branches, and each branch has a condition, the workflow performs an action only when the condition in one of the branches is satisfied. If no condition in any branch is satisfied, by default the workflow moves to the next step.If a step has conditional branches, and each branch has a condition except for the last branch, the workflow performs an action only when the condition in one of the branches is satisfied. Else, if no condition is satisfied, the workflow performs the action in the last branch, which has no condition.
Top of PageBefore you begin
Before you design the workflow, you need to make any necessary changes or customizations to your site, list, or library — for example:A workflow is always attached to exactly one SharePoint list or library. Your site must have at least one list or library before you create a workflow. If there are no lists in your site, you are prompted to create one when you create a workflow.If you want your workflow to use any custom columns or settings, you must make those changes before you create the workflow so that those columns and settings are available to you in the Workflow Designer.If you want your workflow to use any list or library features that are not turned on by default, such as Content Approval, you must turn on these features before you design the workflow.
Note The workflow feature is built on the Microsoft Windows Workflow Foundation, a component of Microsoft Windows. The same version of the Workflow Foundation must be installed on both your computer and the server. The first time that you create a workflow, you may be prompted to install the Workflow Foundation.
Top of PageDesign the workflow
The basic steps of creating a workflow are always the same: First you define the workflow, and then you create the rules by choosing conditions and actions.On the File menu, click Open Site.In the Open Site dialog box, browse to and select the SharePoint site where you want to create the workflow, and then click Open.On the File menu, point to New, and then click Workflow.
The Workflow Designer opens.
In the Give a name to this workflow box, type a name for this workflow.
Site visitors will see this name when they view the Workflow Status and Workflows pages in the browser. By default, new workflows are automatically named Workflow 1, Workflow 2, and so on.Click an option in the What SharePoint list should this workflow be attached to? list.
You must attach your workflow to a SharePoint list or document library. Which list you attach the workflow to determines where the workflow participants start the workflow. For example, if you want a workflow to start when an item is created or changed in Shared Documents, choose that library. The attached list is where you go to check workflow status and history, or to manually start a workflow.
Note Workflows that start automatically when an item is created or changed can run in infinite loops, which you want to avoid. For example, a workflow that starts when an item is changed should never change an item in the list that it is attached to. A workflow that starts when an item is created should never create an item in the list that it is attached to. This is also an issue with multiple workflows. For example, Workflow A is attached to List A, and Workflow B is attached to List B. Both workflows start automatically when a new item is created. Workflow A creates an item in List B, and Workflow B creates an item in List A. Such a scenario creates an infinite loop. A best practice is to know what workflows are already running on any lists or libraries where your workflow creates or changes items.Under Select workflow start options for items in this list, do one or more of the following:Select the Allow this workflow to be started manually from an item check box.
This option adds a Workflows command to a list item so that users can click the command to start the workflow for that item.Select the Automatically start this workflow when a new item is created check box.Select the Automatically start this workflow whenever an item is changed check box.
Note You can select two or three options, but you must select at least one option if you want to run the workflow. If you do not select an option, you can design the workflow and then click Finish, but the workflow cannot be initiated. Later, you can open the workflow (File menu, Open Workflow command), select an initiation option, and then click Finish. This is useful for saving a workflow that you are in the process of designing.Click Next.In the Step Name box, type a name for the first step of your workflow.
Now you create the rules for your workflow by choosing the actions that you want it to perform and any conditions that must be satisfied for those actions to occur.
Note Not every step must contain a condition; for example, you can have steps that are simply a list of actions to be performed. However, every step can have at most one conditional branch that contains an action without an associated condition. This is because a conditional branch that does not have a condition acts as the “”Else”” branch in an “”Else If”” conditional branch. If condition A is true, do action B; otherwise — else — do action C. As such, it would not make sense to have more than one “”Else”” branch because the last branch would never be reached.
For each condition that you want to specify, click Conditions, and then click that condition in the list. Repeat until you have specified all of the conditions that you want to include.
Note You can choose more than one condition. If you do, the conditions are joined by and, meaning that all the conditions must be satisfied before the workflow does the associated actions. Multiple conditions create a progressive filter in which the order matters because the first condition is evaluated first. To move a condition up or down in a list of conditions, click the condition, click the down arrow that appears, and then click either Move Condition Up or Move Condition Down in the list.
Office SharePoint Designer 2007 provides a number of predefined conditions. In addition, you can create advanced and custom conditions. With custom conditions, you can compare a field in the current list with a value. With advanced conditions, you can compare one value to another value. This allows you to create a comparison between a field in any list and a value from a wide range of sources.
After you insert a condition, click each hyperlink, and then choose a value for the required parameters.
For example, a condition might include links for choosing a field in the list, a comparison, and a value.
For each action that you want to include, click Actions, and then click that action in the list. Repeat until you have specified all of the conditions that you want to include.
If this action does not appear in the list, click More Actions, click the action that you want, and then click Add.
Note You can create more than one action for a condition. If you do, the actions can run either one after another (joined by “”then””) or at the same time (joined by “”and””). To switch between running in sequence and running in parallel, click the arrow in the upper-right corner of the rule, and then click either Run All Actions in Sequence or Run All Actions in Parallel.After you insert an action, click each hyperlink, and then choose a value for the required parameters.
For example, an action might include a link for creating an e-mail message.
If you want to add a conditional branch, click Add ‘Else If’ Conditional Branch, and then repeat steps 9–12 to create another rule.
A rule is a set of related conditions and actions, as shown in the previous illustration. When the condition is true, the workflow does the associated actions. But what if the condition is not true? By adding conditional branches, you can specify additional conditions. For example, you can create three different conditions for when a document status is changed to Approved, Rejected, or Pending. You can also create an Else condition, where the workflow performs the action only when none of the previous conditions have been satisfied. To create an Else condition, the last rule in the step must be an action with no conditions. The workflow evaluates all the conditions; if none of them are satisfied, the workflow performs any actions in the final branch, which has no condition.When this step of the workflow is complete, click Next.For each step in the workflow, repeat steps 8–14 to create additional sets of conditions and actions.
As you add steps, keep in mind that each step can hold only one set of ‘Else If’ conditional branches, where the actions in each branch are performed only when the associated condition is satisfied. In this case, you must add additional steps when:Multiple sets of ‘Else If’ conditional branches need to be evaluated.You need to separate a branched statement from a non-branched statement.To check the workflow for errors before you exit the Workflow Designer, click Check workflow.
If there is a workflow error, the hyperlink changes color and asterisks appear before and after the invalid parameter. In addition, under Workflow Steps, an error symbol appears next to each step that contains an error. For each error, check to make sure that the parameters entered are valid.Click Finish. The workflow is saved and attached to the list that you specified.
Note You cannot change which list a workflow is attached to after you save the workflow. Instead, you must create a new workflow and attach it to the list that you want.