Building Workflows in Sharepoint 2010

Terminology
  • Workflow template - A workflow template is a reusable workflow solution that has been deployed and installed in your Sharepoint environment as a feature. Like all features, it must first be activated before it can be used. By default, the out-of-the-box templates are activated, but if you create a custom workflow template, make sure to check whether the feature is activated before you attempt to create a workflow based on that template. Use the following steps to check the feature settings in your site collection:
    1. From the top-level site in your site collection, click Site Actions --> Site Settings.
    2. Under the Site Collection Administration section, click Site Collection Features.
    3. Ensure that the workflow features have a status of Active.
     
  • Workflow association - A workflow association is a specific connection between a workflow and a target list, library, content type, or site. For example, when you add an out-of-the-box workflow to a document library, you are taking the existing workflow template and creating a workflow association between the workflow and the document library.
  • Workflow instance - A workflow instance is the individual workflow process running on a specific item or site, based on a specific workflow association. When you are usingan approval workflow in a list and the workflow is set to start on item creation, when an item is created, a new workflow instance starts running on the item.
  • Reusable workflow - As the name suggests, a reusable workflow is any workflow that can be reused in your Sharepoint environment. However, this can be a bit confusing. In the past, workflows were reusable only if they were created as workflow templates. THis meant that a workflow had to be an out-of-the-box template or a custom solution created in Visual Studio. However, Microsoft Office Sharepoint designer 2010 is now capable of creating "reusuable workflows". These workflows will not be as reusable as workflow templates, but nonetheless they are reusbale. These types of workflows are covered later in the section "SPD 2010."

  • Workflow Association Types

    • Lists/ Libraries : By creating the association at this level, the workflow will run only on items created within the specified list or library. If you were to save this list or library as a template, any out-of-the-box workflow templates used would be associated with the template, making them part of anything created from the template.
    • Comment Types - By associating the workflow with a content type, the workflow will run on all items created with this content type. This allows for a reusable workflow solution if you were to use the specified content type in multiple lists or libraries. The management features in Central Administration enable you to reuse a content type with a workflow across sites, site collections, and web applications.
    • Sites - Some workflows are not associated with list and/ or library items and are triggered by a different mechanism. Workflows of this nature can be associated at the site level. The ability to associate workflows with sites  means workflow authors are no longer required to use list and library items. Possible  scenarios for this would be for the workflow to run when the home page of the site was edited or a new Web Part was added to the page. Only workflows created with SPD 2010 and Visual Studio 2010 can be associated at the site level.

    Using the Ribbon

    It is here that you will fine workflow options for sites, lists, libraries, items and documents.

    We will first look at the Site Workflows option, which you can find on the All Site Content Page of the current site (See Figure 1). By clicking the link for Site Workflows, your browser will take you to the "Workflows:[your site]" page, where you can start a new site workflow or view information about existing workflows.


















    Figure 1

    In a document library, when you click on the Documents tab under Library Tools, the Ribbon will contain a set of available options that you can perform on a document. Toward the right, there is a section titled Workflows (see Figure 2). This section has several options:


    Figure 2
    • Workflows - This is the link you will primarily be concerned with. By clicking the Workflows link, called out in Figure 2, you will be taken to the 'Workflows:[document name]" page. From here you can manually start a new workflow or view information related to workflows that are currently running on the item. Workflows that you can start on the item are displayed at the top of the page. These options vary according to the type of library or list that you are in. For a document library, you should see options for several out-of-the-box workflows. For lists, these same workflows may not be available. If you have created a specific workflow association that is set to start manually, you should also see the option to start that workflow.
    • Publish - if versioning is enabled, this link will publish a major/minor version of the document.
    • Unpublish - if versioning is enabled, this link will unpublish the current version of the selected document.
    • Approve/Reject - If Content Approval is enabled, this option will be available to users with Approval permissions to reject or approve documents.
    • Cancel Approval  - this option will cancel the approval of the selected document.

    If no documents have been selected, many of these options will be grayed out. When you select a document, these options become available, although for some documents these options may not be available until you create a specific workflow association or you enable specific features such as Versioning and Content Approval.

    The other option you will see under Library Tools is Library. Clicking this tab displays all of the options you have for configuring the document library itself. On the far right is the option for Workflow Settings. Clicking this drop-down menu will display several options, as shown in Figure 3.



    Figure 3














    • Workflow Settings - Selecting this option will take you to the "Workflow Settings: [library]" page. Here you can see all workflow associations that exist on the library. If you have several workflows running on multiple content types, a drop-down menu enables you to select a content type to view. In addition to the existing workflow associations, you have links to Add a workflow, Remove a workflow, and View workflow reports.
    • Add a Workflow - Although this option is also available through the Workflow Settings link, it is important enough to have it here as well. Clicking this link takes you to the "Add a Workflow: [library]" page. Here you can select a workflow template to create a workflow association with your library. Depending upon the template you choose, you will be prompted for various configuration options, but each template should require you enter a unique name, task list, history list, and start options.
    • Create a workflow in SPD - When you click on this link, SPD 2010 will open and pop up a new window for creating a new workflow. 
    • Creaet a Reusable Workflow in SPD - When you click on this link, SPD 2010 will open and pop up a window for creating a new reusable workflow. This option is also be covered later in the section "SPD 2010".

    Workflow Intitialization

    • Start manually - This option enables users to manually start a workflow on an item of their choosing. The only requirement is that the user must have Participate permissions on the item where the workflow will run. However, if the creator of a workflow association selects the option to start the workflow manually, he or she may also choose to configure the workflow so that only users with the Manage Lists permission can start the workflow. Manually starting the workflow is not the ideal option, as it puts additional responsibility on the user.
    • Start on item creation - This option will start the workflow as soon as a user creates or uploads a new item to the list or library. This start method is more commonly used because it requires less user responsibility and the workflow is guaranteed to run for every content type in the list or library.
    • Start when an item is changed - This option will start the workflow when an item is edited. If a workflow instance is already running on an item, then it will be terminated and the workflow will restart. You can have only one workflow instance running on an item at a given time.
    • You can select multiple or all options -Make sure you understand the implications of having multiple start methods. The obvious concern is interference with the business process: Triggering a workflow to start when another workflow is running will cancel the previous instance. It is also possible to use this feature to create an infinite loop, which is never a good thing.

    CONFIGURING WORKFLOWS USING THE BROWSER

    Out-of-the-Box Templates

    • Three State - This workflow is used to track items in a list. It does this by using a predefined choice column. The column has 3 choice values that correspond to the three "states" of the workflow: Initial State (Active), Middle State (Resolved), and Final State (Closed). In the configuration page for this workflow, you specify this column and then set the task details for each choice value. When an item is running an instance of this workflow, as the item's specified choice column is updated, the task details for that choice column value, or state, is triggered, and then moves on to the next state. An example of this workflow would be on a Help Desk item that had three states defining its status: Open, Pending, and Closed. Different users would be assigned tasks based on the status of the item.
    • Approval -  This template routes a document for approval. Users that have been assigned as approvers  can approve or reject the document, reassign the approval task, or request changes to the document. During the configuration process, you can specify the approvers and define stages of the workflow.  If the workflow is started manually, the user who starts the workflow can specify which users the workflow notifies for document approval. Each stage can have a different set of approvers; and you can also define whether you want the stage approval to run serially or in parallel. Serial approval causes the workflow for that stage to request approval for each specified user, one at a time. The workflow will move on to the next stage, or complete the workflow, when the last user has completed his or her task. Parallel approval creates tasks for every user specified at the same time, and waits for all of them to complete their tasks before moving on. An example of this workflow would be a defined two-stage approval process for a Time Off request submitted as a Microsoft Word document. The first stage might be manager approval, and the second stage could be the Human Resources department confirming that the employee has available time off.
    • Disposition Approval - This template supports both records and document management. Working in conjunction with a preconfigured Expiration Policy section of an Information Management Policy, this workflow will assign a task to a specified user who reviews the item and then approves or rejects the item's deletion. This workflow is invaluable in situations where records and document management are paramount. A common example would be an organization that has a mandatory three-year retention requirement for storing documents related to a project. The organization could use the Disposition workflow to work with an expiration policy so that the project manager would be assigned the task of deleting the project documents after the necessary time had elapsed.
    • Collect Signatures - This template will automatically request assigned users to add their signatures to a document. These requests are similar to the Approval workflow, but you are not able to configure the notification message, duration information, and other configurations. The Collect Signatures workflow request is very basic. The assigned users can be specified when the workflow association is created and/or when a user manually starts the workflow. Even though the usage information of users can be tracked within most applications, some organizations still require an actual signature on documents. For those situations, this workflow is ideal.
    • Publishing Approval - Similar to the Approval template, this template is specifically for the approval of publishing page items,
    • Collect Feedback- This template forwards the document to assigned users who will provide feedback. These requests can be configured the same way Approval workflows can be configured. Once the workflow is completed, all the feedback is compiled and forwarded to the user who initiated the workflow.