Introduction to workflows

Across your enterprise, teams use Microsoft SharePoint sites to collaborate on documents and share information. You want to build a SharePoint application that improves team productivity and efficiency, but you don’t want to write code. Where do you start?

With Microsoft Office SharePoint Designer 2007, you can design workflows that add no-code application logic to your SharePoint sites and applications. Using the Workflow Designer, you create rules that associate conditions and actions with items in SharePoint lists and libraries. Changes to items in lists or libraries trigger actions in the workflow.

For example, suppose that a team's primary responsibilities are writing, revising, and approving contracts. These contracts are stored in document libraries on the team site. With Office SharePoint Designer 2007, you can create a workflow that sends a notification e-mail message to the reviewer when a new contract has been uploaded to the site. At the same time, the workflow creates a task in the Tasks list for the reviewer. When that person reviews the contract and marks the task as complete, different actions are triggered depending on whether the contract is assigned a status of Approved or Rejected.

Team efficiency and productivity improve because the workflow drives the process so that the team can focus on doing the work, rather than on managing the workflow. And no programming is required to build such a solution. By creating rules in the Workflow Designer, you can quickly add interactivity to a SharePoint solution or application.

This article introduces the basics of workflows. When you understand the basic building blocks of a workflow — events, actions, conditions, and steps — you can quickly add application logic to your SharePoint applications.

 Important   To create a workflow, your SharePoint site must be located on a server running Windows SharePoint Services 3.0.

In this article


What is a workflow?

Your team uses a SharePoint site to collaborate and store valuable business information in SharePoint lists and libraries. With Office SharePoint Designer 2007 , you can now attach application logic to documents or items in these lists and libraries.

With the Workflow Designer, you can attach a sequence of conditions and actions to a list or library — this sequence is a workflow. A workflow is a natural way to organize and run a series of actions that correspond to a work process. This process can control almost any aspect of a list item in Windows SharePoint Services 3.0, including the life cycle of that item. The workflow can include both actions performed by people (or workflow participants) and actions performed by the workflow. Workflow participants can interact with the workflow through the Tasks list, where a workflow can create a task for someone and remain paused until the task is marked complete.

Workflows can be as simple or as complex as your business processes require. You can create a workflow that the user initiates, or a workflow that is initiated automatically based on an event, such as when a list item is created or changed.

In general, when you use Office SharePoint Designer 2007 to design a workflow, you follow these basic steps:

  • Use the Workflow Designer to choose and assemble the conditions and actions that define the steps of the workflow.
  • Have Office SharePoint Designer 2007 automatically generate any ASP.NET forms for workflow initiation or any custom SharePoint task, if necessary.
  • Customize the workflow forms, if necessary.

You can think of a workflow as a flowchart of actions with a beginning, an end, and a sequential flow from start to finish. Workflows can incorporate parallel branches, but ultimately they progress from the initial action to the final action.

For example, suppose you were to chart the workflow described earlier that routes a document in Windows SharePoint Services 3.0 for approval. When the workflow starts, it automatically notifies the specified reviewer by e-mail that they have a document to review. The reviewer then reviews the document, and changes the status of the document to indicate that they have completed their task, and whether they have approved or rejected the document. Based on the reviewer response, the workflow proceeds down one of two parallel branches. If the reviewer approves the document, the workflow moves the approved document to a specific document library, and then sends an e-mail message to the entire team notifying them of the approved document. If the reviewer rejects the document, the workflow notifies the document author of this. In either case, the workflow then reaches its end and the process is completed.

Workflow process flow chart

Top of Page Top of Page

What are events, actions, conditions and steps?

These are the building blocks of a workflow. A workflow consists of one or more steps, and each step consists of actions and any associated conditions. Each workflow is initiated by an event.

What are events?

An event is what starts or initiates a workflow. There are exactly three events that can start a workflow:

  • An item is created.
  • An item is changed.
  • A workflow participant clicks a start button on the SharePoint site.

It is important to understand that a workflow created with Office SharePoint Designer 2007 is always attached to exactly one list or library in a SharePoint site. When you design a workflow, you choose which list to attach it to. An event in this list starts the workflow.

You can create a workflow that a participant starts manually, or a workflow that is started automatically when a list item is created or changed. For example, in the document approval workflow, you want to design the workflow so that it starts automatically whenever someone adds a document to the Shared Documents library. On the File menu, point to New, and then click Workflow. In the Workflow Designer, you see the following page.

Define workflow - document approval

When a workflow participant starts a workflow manually, that person first browses to the list or library that the workflow is attached to. Any person with at least the Contribute permission level can initiate a workflow that is designed to start manually. The participant clicks an item, clicks Workflows on the menu, and then chooses a workflow from a page that displays all workflows associated with that item. The participant fills out a workflow initiation form, if necessary, and then initiates the workflow by clicking the start button on the form. Initiating a workflow creates a new instance of that workflow for that specific item.

Workflow command on list item

 Note   The Workflows command is available only when the item is in a list or library that has at least one workflow attached to it.

For a workflow that is started manually, the initiation form can be as simple as the following.

Example of workflow start button on list item

You can also add custom fields to an initiation form when you design the workflow. Workflow participants can then provide information to the workflow by filling out this form, and those settings are passed to the workflow. A new workflow instance starts, and that workflow can then look up and use the information provided through the form at any point in the workflow.

What are actions?

An action is the most basic unit of work in a workflow. Office SharePoint Designer 2007 provides a set of ready-made, reusable actions for you to incorporate into your workflow. For example, your workflow can:

  • Create, copy, change, or delete list items (including documents).
  • Check items in or out.
  • Send an e-mail message.
  • Create a task for someone on the Tasks list of your team site.
  • Collect data from a participant that can be referenced later in the workflow.
  • Pause or stop the workflow.
  • Log workflow information to a History list to use for repudiation or workflow debugging.
  • Set workflow variables or perform calculations.

A workflow can contain any number of actions. The actions just listed are performed by the workflow, but other actions might be performed by workflow participants. For example, the document approval workflow is comprised of five actions. Four of these actions are performed automatically by the workflow, but one of these actions — actually reviewing the document — is done by a workflow participant. Actions done by a workflow participant are represented by tasks assigned to that person in the Tasks list. The five actions in the example workflow are:

  • Send an e-mail message to notify the reviewer
  • Review the document (a task assigned to a workflow participant)
  • Move the document to the Approved document library
  • Send an e-mail message to notify the team
  • Send an e-mail message to notify the document author

In the most basic sense, when you design a workflow, you identify the necessary sequence of actions, and then you assemble that sequence of actions by using the Workflow Designer. For example, in the document approval workflow, the first action that you want is to send an e-mail message to notify the reviewer.

Flowchart, send e-mail to reviewer

So in the Workflow Designer, you choose that action for the first step in the workflow.

Actions list

What are conditions?

When you design a workflow, you can use the Workflow Designer to create rules that apply conditional logic to SharePoint lists and items. A rule establishes a condition where the workflow performs the associated action only if that condition is true. For example, you can create a rule where the workflow sends a reviewer an e-mail message only if an item is created by a specific person. You can also add clauses to a condition. For example, you can create a rule where a reviewer is sent an e-mail message only if an item is both (1) created by a specific person and (2) the document title contains specific keywords. Finally, you can associate multiple actions with one condition. For example, you can create a rule where if an item is created by a specific person, then (1) the reviewer is sent an e-mail and (2) workflow information is logged to the History list.

Choose conditions and actions

To sum up, a rule is a condition associated with one or more actions: If all clauses in the condition are true, do all the associated actions.

In the previous example, the user specified only one condition. However, you can create multiple conditions for a step in the workflow. Multiple conditions create branches in the workflow: If condition A is true, do one action; if condition B is true, do a different action. To add a branch to a step, click Add 'Else If' Conditional Branch. For example, in the document approval workflow, if the reviewer approves a document, the workflow performs one action (or series of actions); if the reviewer rejects a document, the same workflow performs a different action. This is a conditional branch.

Flowchart example, approver reviews document

In the Workflow Designer, this step has two branches and looks like the following. The green diamond indicates that the step has a conditional branch.

Conditional branch with two conditions

You can also create a branch that has no specific condition. This way, the workflow performs one action if a condition is true and a different action if the condition is false. For example, the following step in a workflow sends a message to the team only if the condition is true; else, the workflow sends a message just to the document author. By adding a branch with no specific conditions, the workflow performs the action in that branch in any case where the condition in the first branch is false.

Conditional branch with no second condition

 Note   Branching in a workflow cannot extend from one step to another. A set of 'Else If' branches is always contained in a single step.

Office SharePoint Designer 2007 provides several ready-made, reusable conditions for you to incorporate into your workflow. For example, you can specify that the workflow performs the associated actions only if an item:

  • Is created or modified in a specific time span.
  • Is created or modified by a specific person.
  • Has a title field that contains specified keywords.
  • Is a file of a specific type or has a file size in a specific range. (This condition is available only when the workflow is attached to a document library.)

In addition, you can create custom conditions and advanced conditions where you can specify a wide range of parameters. With custom conditions, you can compare a field in the current list with a value. For example, you can create a custom condition where if the Approval Status field equals Approved, do the associated action. 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 another list. For example, you can create an advanced condition for the Shared Documents library where if the value of the Status field in the Tasks list equals Pending, do the associated action.

 Note   An action does not require a condition. For example, the first step of the example document approval workflow sends an e-mail to notify the reviewer. This action does not have a condition associated with it.

Parallel vs. serial actions

When you have more than one action associated with a condition, the actions can be set up to run at the same time (parallel) or one after another (serial).

Run actions in parallel or serial

Serial actions    For example, in the document approval workflow, you can set up two actions so that when a document is approved, a message is sent and then (afterward) the document is copied to the Approved document library. In the Workflow Designer, then indicates that the second action occurs after the first.

Serial action with 'then'

Parallel actions    For example, in the document approval workflow, you can set up two actions so that when a document is approved, a message is sent and (at the same time) the document is copied to the Approved document library. In the Workflow Designer, and indicates that the second action occurs at the same time as the first.

 Note   Parallel actions are not absolutely simultaneous; the exact order cannot be specified and may vary each time the workflow runs.

Parallel action with 'and'

 Notes 

  • In any given rule (conditions and actions), all actions must be either serial or parallel.
  • A set of serial or parallel actions must be contained within a single step.

What are steps?

A workflow is comprised of one or more steps. Each step can contain any number of actions and associated conditions. You can think of steps simply as pages in the Workflow Designer. For example, the document approval workflow has two steps, as shown in the Workflow Designer.

Workflow steps, add a step

Steps allow you to group conditions and actions so that one set of rules (conditions and actions) can be evaluated and performed before a second set.

One step or many? Some workflows can be designed either as a sequence of actions within one step, or as a sequence of steps.

For example, the following three actions could be Step 1 of a basic one-step workflow.

Multiple actions in one step

The same three actions could be separated into several steps.

Multiple actions in many steps

How you structure your workflow into steps depends on what you want each step to accomplish. 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.

More specifically, each step can hold 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, additional steps are needed only when:

  • Multiple sets of 'Else If' conditional branches need to be evaluated.
  • You need to separate a branched statement from a non-branched statement.

You can also use steps simply as a way to organize your workflow. For example, a workflow might have many actions in a step that doesn't use conditions. In this case, you might want to separate the actions into steps just to better organize them.

Top of Page Top of Page

What are workflow forms?

To make your workflow more dynamic and flexible, you can add a form to the workflow. With a form, you can collect information from workflow participants at predefined times in the workflow, and make it possible for participants to interact with the tasks for that workflow.

With Office SharePoint Designer 2007, you can create two types of workflow forms:

  • An initiation form gathers information from the workflow participant when they start the workflow. Initiation forms are displayed to users when they manually start a workflow on a given SharePoint item. With an initiation form, users can specify additional parameters or information about the workflow as it applies to the given SharePoint item. For example, you might use an initiation form to ask who should review a document and by when the review should be completed. Not all workflows need initiation forms. If you do need one, Office SharePoint Designer 2007 automatically generates an ASP.NET initiation form according to your initiation specifications.
  • A custom task form allows workflow participants to interact with tasks in the Tasks list on a SharePoint site. With the Custom Task Wizard, you can easily create custom form fields and add them to a custom task form. When you finish designing the workflow, Office SharePoint Designer 2007 automatically generates the ASP.NET forms for your custom tasks. Then, when the workflow runs and tasks are created, the user browses to the Tasks list on the SharePoint site, marks the task as completed, and enters any optional or required information specific to the workflow. The workflow can then respond to those changes as specified in the workflow, or look up and evaluate that information in later steps of the workflow.

After Office SharePoint Designer 2007 automatically generates the ASP.NET forms, you can customize them. Workflow forms are ASP.NET pages with a Data Form Web Part and a master page applied to it. These .aspx files are stored on the SharePoint site with the workflow source files. You can open and customize these forms as you would any other .aspx file.

Top of Page Top of Page

Where are workflows stored?

Workflows are stored in a site-level document library called Workflows. This document library is created automatically by Office SharePoint Designer 2007. In the Folder List, the Workflows document library displays the workflow icon instead of the usual list or document library icon. By default, the Workflows document library is hidden from the browser and has no List Views, such as AllItems.aspx or EditForm.aspx. This document library contains a folder for each workflow created with Office SharePoint Designer 2007. The folder contains all the source files necessary for the workflow, including:

  • The workflow markup (.xoml) file (needed only when the workflow uses conditions).
  • The workflow rules file.
  • The workflow configuration file.
  • Any .aspx forms needed, such as initiation forms (for workflows that are started manually) or custom task forms.

To modify an existing workflow, you can either click Open Workflow on the File menu or double-click the .xoml file in the Folder List. This opens the workflow to its first step in the Workflow Designer. If you click Back to view the initiation settings of the workflow, you see that you cannot change which list or library the workflow is attached to. After a workflow is attached to a list or library by using Office SharePoint Designer 2007, this association cannot be changed.

Workflows in folder list

The Workflow Designer provides an action called Log to History List. You might use this action when you want to keep a record of the workflow history for investigating errors or for tracking and repudiation purposes. When you create a workflow that uses the action Log to History List, Office SharePoint Designer 2007 automatically creates a list called Workflow History. This list has columns for such information as user ID, date, event, and error description. Like the Workflows document library, by default the History list is hidden from the browser but can be seen in the Folder List.

Workflow history in folder list

The Workflow Designer provides three actions that interact with the Tasks list: Assign a To-Do Item, Collect Data from a User, and Assign a Group Survey. When you create a workflow that uses any of these three actions, Office SharePoint Designer 2007 automatically creates the .aspx form, the content type for the task, and the Tasks list, if necessary. By default, the Tasks list can be viewed in the browser, unlike the Workflows document library and Workflow History list.

Tasks list in folder list

Top of Page Top of Page

Where can I check the status of a workflow?

You can easily view the progress of workflows on a selected item through the browser. The All Items view of a list or document library displays the current status of workflows running on an item. In addition, each item has a Workflows page where you can view the following information:

  • All workflows currently running on that item.
  • All workflows that have run on the item in the past.
  • All the available workflows for that item.

Workflows page for an item

To view the Workflows page for an item, click the item in the list, and then click Workflows on the menu.

 Note   The Workflows command is available only when the item is in a list or library that has at least one workflow attached to it.

When a user starts a workflow on an item, Windows SharePoint Services 3.0 adds a new column to that item. By default, the column name matches the name of the workflow. This read-only column displays the current status of the item within that workflow. This status column is added automatically for each workflow the first time it is run.

Columns display workflow status

In each column, the workflow status is a link. When you click In Progress, for example, you see the Workflow Status page for that instance of the workflow.

Workflow status page

A workflow created in Office SharePoint Designer 2007 cannot be deployed to multiple lists. It is only valid for the list for which it was created. However, multiple workflows can be attached to one list and may be available for a given item. Multiple workflows can run simultaneously on the same list item, but only one instance of a specific workflow can run on a specific item at any given time. For example, you might have two workflows, Workflow A and Workflow B, available for a specific list. Although both workflows can run simultaneously on a specific item in the list, you cannot have two instances of Workflow A or Workflow B running on the same item at the same time.

Top of Page Top of Page

Suggested next steps

Workflows are a powerful way to add application logic to your SharePoint sites and applications. Now that you understand the workflow basics, you might want to get started by creating a workflow:

  • For some important design considerations and a basic, generic procedure, see the article Create a workflow.
  • For links to articles that present complete workflow examples, see the See Also section.

Top of Page Top of Page

 
 
Applies to:
SharePoint Designer 2007