A workflow is a natural way to organize and run a set of work units, or activities, to form an executable representation of a work process. A workflow is a set of co-ordinate event-driven activities. Assigning workflow to a document or a piece of content is the act of binding a business process to this entity. Suppose you need to create a simple workflow that routes a document to a series of users for approval or comments. This workflow would include actions that the system needs to perform, as well as provide interfaces for the users to interact with the workflow in prescribed ways. For example, Windows SharePoint Services would send an e-mail message to the selected users when the document was ready for review. Those users would then need to be able to notify Windows SharePoint Services when they had completed their reviews and, optionally, enter any comments.
Types of Workflow
SharePoint workflows are based on Windows Workflow Foundation (WF) which is a base set of technologies that programmers can access using Visual Studio or SharePoint Designer.
There are two types of workflow supported:
1. Sequential - This is similar to a flow chart style where there are decision points along the way that indicate what the next step is in the workflow based on some condition being met (or not met). These steps generally execute in a specific order.
2. State Machine - This style workflow is more complex and consists of a number of states, transitions between states and actions.
Workflow ArchitectureThe basic components of a workflow include:
1. An XML-based markup file that contain the basic information about the workflow and the activities contained within it
2. An XML-based rules file that contains the business logic of the workflow in declarative rules form
3. One or more aspx or Info Path forms
Unless you are using SharePoint Designer, workflows are compiled into assemblies and installed as features at the site collection level.
Workflow associations are stored in the database for SharePoint. For each type of content (document, list, or a content type), an association is made is made in the table. You can have more than one workflow associated with a content type, but they can't be the same type of workflow (i.e. you can have an approval and a translation workflow, but not two approval workflows). In addition, workflows can be manually initiated or system initiated based on an event (i.e. changing the content).
SharePoint Administration: Workflow Settings
There is an administration option for workflows that allows you to set some global settings at the Web Application level. These setting include whether user-defined workflows are enabled and how users who don't have site access are notified of their participation requirements in a workflow (i.e. they are assigned a task).
Out the box Workflow
SharePoint provides a base set of workflows out of the box including:
1. Approval workflow
2. Collect Feedback
3. Collect Signatures
4. Disposition Approval
5. Three-state
6. Translation Management
Not all of these workflows are turned on by default. To see what's activated, view the Features at the Site Collection level.
By default, when you create a publishing site with workflows, an approval workflow is automatically attached to each content type created for the site. You can add new workflows through Site Actions…Site Settings…Modify Pages Library Settings.
Creating Workflows in SharePoint Designer 2007
You can use SharePoint Designer 2007 to create custom workflows for your site. The designer enables you to create workflows using a wizard type approach. This does have limitations.
The wizard is declarative rules-based and code-free. You can’t create activities using this wizard, you can only select from a pre-defined list. The other drawback is that you create the workflow for a particular site and for a particular list or document within that site. You cannot create a workflow for a content type using the designer.
To create a workflow, open the site you want to add it to and select the list type to attach the workflow to (see figure below).
You can create one or more steps for your workflow. For each step you assign conditions and actions when the condition is met. If you have multiple actions to take you can apply them in one of two ways:
1. Serial: the actions happen in a specific order (denoted by “then”)
2. Parallel: actions can occur at the same time (denoted by “and”)
You can also create forms to make the workflow more dynamic and flexible. In SharePoint Designer you can include 2 types of forms in your workflow:
1. Initiation forms – these are the forms that gather information when the workflow is first activated
2. Custom task forms – these allow users to interact with the tasks in the Task List
The designer generates the forms as aspx pages and stores them with the source files for the workflow. You can open these aspx files in Designer or another editor and modify them.
When you have completed creating your workflow, two source files are generated and stored in a document library within the site. The workflow is not compiled into an assembly, rather when the workflow is initiated; the source files are compiled and stored in memory. There are two XML-based source files:
1. Markup File: outlines the activities included and the basic workflow information
2. Rules File: contains the business logic of the workflow in declarative rules form
Creating Workflows in Visual Studio 2005
Creating workflows in Visual Studio 2005 is much more involved than using SharePoint Designer, but it’s also much more robust. Workflows created using Visual Studio are compiled assemblies with each activity in the workflow represented by a .net class.
Visual Studio has a workflow designer that you use to create your workflows. There is a graphical representation of your workflow that you create by clicking and dragging components in the interface.
Only a subset of the WF activities is available when designing a workflow for a SharePoint site. However, in addition to these activities, SharePoint itself provides a number of activities via its own workflow namespace (API).