In-Depth

A SharePoint Workflow Primer

Microsoft Office SharePoint Server is one of the hottest products in Redmond's arsenal and can provide a major productivity boost for companies. In this four-part guide, we detail how IT administrators can get the most out of SharePoint by effectively using workflows.

SharePoint has always done a great job of managing and maintaining document libraries, but sometimes just having a document library isn't enough. Often times, companies can greatly benefit from building some intelligence into their document libraries. In SharePoint 2007, this intelligence can be achieved through workflows.

I'll describe workflows in more detail later on, but they're essentially a set of steps that can be applied to a document library to make that document library adhere to a company's business processes. For instance, imagine that you work for an advertising agency. Although there would no doubt be some sharp people coming up with the various ad campaigns, you wouldn't expect the person who comes up with an idea for an ad to type the ad up and deliver it directly to the magazine that will be running the ad.

Instead, a company like this one probably has a set of formal processes in place to control how advertisements are released to publishers. For example, the person who comes up with the ad might forward it to an art director who is responsible for making the ad look better. Once the art director does his or her thing, the art director might forward the ad to an editor, who makes sure everything is spelled correctly and is grammatically sound. That person might then forward the ad to the legal department to make sure that the ad isn't worded in a way that could cause the client to have legal problems. The legal department might then send the ad to an executive manager, who gets the client to sign off on the ad -- and who then sends it to the publisher.

I've never worked for an advertising agency before, so this may or may not be the way that they work in real life. That isn't the point, though. The point is that, like my fictitious advertising agency, most companies have some sort of workflow process in place, but ultimately end up having to trust their end users to follow the process rather than having an automated mechanism in place to make sure that the process is adhered to.

SharePoint workflows can provide this automated workflow process. In many organizations, using SharePoint to automate workflows can make things run efficiently. After all, SharePoint can notify the next person in line that there's a task that he needs to perform, so he doesn't have to wait to be told to do a job or periodically check to see if there's anything that needs to be done. In other situations, having workflows in place might be able to help companies to adhere to federal regulations that specify the way in which certain types of information must be handled within the company.

Figure 1
[Click on image for larger view.]
Figure 1. You must verify that SharePoint workflows are enabled.

Now that I've given you a basic idea of what workflows are capable of, I want to talk a bit more specifically about what workflows are and what they do. If the concept of workflows sounds familiar to you, it's probably because SharePoint has a long history of them. In 2001, Microsoft released SharePoint Portal Server, which supported workflows. When Microsoft created SharePoint 2003, though, it removed most of the workflow-related features; however, a lot of third-party software publishers have stepped in and created applications that provide workflow functionality.

In SharePoint 2007, workflows are essentially activities that are triggered by events. There can be one activity in a workflow, or multiple activities. Having the ability to create a complex chain of activities is what makes SharePoint workflows so powerful.

Although it's possible to create some rather complex workflows, doing so doesn't have to be complicated. The tool of choice for creating workflows is Visual Studio, but in SharePoint 2007, Microsoft has provided an interface that you can use to design workflows graphically without having to write any code. This interface is suitable for designing all but the most advanced workflows. I'll show you the design interface later on in this article.

One more thing I want to mention about workflows is that they're usually used with document libraries, but SharePoint 2007 also allows you to use them with lists. In case you're not familiar with lists, they're very similar to spreadsheets -- except that they're designed to be collaborative in nature, so multiple users can work on a list simultaneously.

Now that you know what workflows are and what they can do, I'll discuss SharePoint's predefined workflows.

Using Predefined SharePoint Workflows
If you've done much work with SharePoint 3.0, then you know that while it's possible to create a three-state workflow, it requires a bit of effort. When Microsoft created SharePoint 2007, one of its goals was to make workflows easier to use. In doing so, Microsoft created two preconfigured workflows and several different workflow templates.

Getting Started
Before I show you how to use any of the built-in workflows, you'll have to verify that workflows are enabled for the collection of SharePoint sites. To do this, open the SharePoint Central Administration console and then click on the Application Management tab. Next, click the Workflow Settings link found in the Workflow Management section. When you do, you'll see a screen similar to the one that's shown in Figure 1. Make sure that workflows are enabled, and then click OK.

Applying a Predefined Workflow
Now that you've verified workflows are enabled, it's time to take a look at the predefined workflows built into SharePoint 2007. Open a document library and click on the Properties icon for a document. SharePoint will display a number of different options for the document. You'll now see a screen similar to the one shown in Figure 2.

Figure 2
[Click on image for larger view.]
Figure 2. SharePoint contains two built-in workflows.

Figure 2 shows two built-in workflows. One is called Approval and the other is called Collect Feedback. To see how these workflows work, click the Approval icon. You'll see a screen similar to the one in Figure 3.

Figure 3 shows the predefined Approval workflow. We're going to use this workflow to stipulate that the document we clicked on earlier requires approval. In order to require this approval, though, we must provide SharePoint with some information.

Figure 3
[Click on image for larger view.]
Figure 3. You must fill in some information for the document-approval workflow.

The first thing that we have to tell SharePoint is who the designated approver for the document is. The easiest way to do this is to click on the Approvers button and type the username for the person you want to do the approval. When you press enter, SharePoint will search Active Directory for the user that you've requested.

Once this user is displayed, click the Add button, then the OK button. Keep in mind that you don't necessarily have to limit yourself to having a single approver: You can enter multiple user accounts, or even specify a group.

The next thing you'll do is select the Assign a Single Task to Each Group Entered check box. This allows SharePoint to notify the designated approver that there's a document pending approval. Just beneath this check box is a field where you can enter a message to the approver.

The next option available to you is the Due Date option. The basic idea behind this option is that most of your users probably have a certain deadline by which a document needs to be submitted. Setting a due date gives the user a way to tell the approver what their deadline is. If the approver has not approved the document by the due date, an e-mail reminder is automatically sent to the approver on the due date.

The last option on the screen is the Notify Others option. This gives you a way to notify other users in the organization that the document has been submitted for approval, without assigning a task to them.

Once the various options have been filled in, click the Start button and the workflow will begin. Nothing obvious happens after you click the Start button to indicate that the workflow has been launched, but there are ways of monitoring the workflow. If you click the Properties button, followed by the Workflows button, you'll see a screen indicating that the Approval workflow is currently in progress. If you click the In Progress link, you'll see a screen similar to the one that's shown in Figure 4.

Figure 4
[Click on image for larger view.]
Figure 4. Clicking the In Progress link displays the current state of the workflow.

As you can see in the figure, SharePoint gives you a breakdown of the workflow progress. This particular screenshot displays an error message, but that's only because I didn't take the time to configure the server's outbound e-mail settings.

Creating Custom SharePoint Workflows
Now that you know how to use SharePoint 2007's built-in workflows to create a simple document-approval process, I'll show you how to build a SharePoint 2007 workflow from scratch.

Getting to the location where you can create custom workflows is not exactly an intuitive process. You must begin by opening your document library and clicking on the Site Actions link. SharePoint will present you with three choices that can be used as site actions. Choose the Site Settings option. When the Site Settings page is displayed, click the Site Libraries and Lists link (found in the Site Administration column). Click on the Customize Documents link, followed by the Workflow Settings link. You should now see the Add a Workflow screen, shown in Figure 5.

In the previous section, I mentioned there were several workflow templates built into SharePoint. The first step in creating a custom workflow is choosing a template off of which to base that workflow. We'll use the same Approval template as we did with the predefined SharePoint workflow so you can see how creating a custom workflow differs.

The next thing you'll need to do is to enter a unique name for the workflow. You can call the workflow anything you want, but I recommend using a descriptive name.

After entering a name, select a Task list and a History list that the workflow can use. It's usually considered a best practice to use one of the existing Task and History lists.

The last thing you'll do on the screen is set your start option for the workflow. As you can see in Figure 5, you have several options: allowing the workflow to be manually started; using the workflow to approve a major version of an item; starting the workflow when a new item is created; or starting the workflow when an item is changed. Keep in mind that you're not limited to a single choice: You can select multiple start options.

Figure 5
[Click on image for larger view.]
Figure 5. Locating the Add a Workflow screen can be a little tricky.

When you've filled in the various options, click Next. You'll be taken to the screen shown in Figure 6, where the first thing you must do is choose how Workflow Tasks are assigned. For example, you'll decide whether tasks should be completed by one participant at a time or if they can be completed simultaneously by all participants. You can also choose whether or not the participants are allowed to reassign tasks or request changes to tasks.

The next section on the screen allows you to enter some Default Workflow Start Values. The options here are identical to the options shown in the previous section of this article. This is where you enter your list of approvers, a message to the approvers, a due date and the notification list.

Figure 6
[Click on image for larger view.]
Figure 6. You must decide on the basic rules for Workflow Tasks.

Because this is an Approval workflow, you can choose for it to be completed when a document is changed or when a document is rejected. You can see what this section looks like in Figure 7.

Post-Completion Workflow Activities is the last section on this screen. As you can see in Figure 7, you can tell SharePoint to perform some sort of action after the workflow is complete. In the case of an Approval workflow, your only option is to update the workflow's approval status.

Figure 7
[Click on image for larger view.]
Figure 7. The Complete the Workflow section allows you to determine the criteria that constitute a complete workflow.

Click OK and the workflow is created. You'll now see the workflow displayed on the screen that's shown in Figure 8. This screen allows you to modify the workflow settings, create another workflow or delete the workflow that you've just created.

Figure 8
[Click on image for larger view.]
Figure 8. The Change Workflow Settings screen allows you to create, delete or modify workflow.

Using the SharePoint Designer
At this point, I've talked all about creating workflows with SharePoint. In this final section, I want to wrap things up by showing you how to create workflows through the SharePoint Designer.

First, for those of you who are not familiar with the SharePoint Designer, it's the Microsoft Office 2007 version of what was previously known as Microsoft FrontPage. The SharePoint Designer allows you to create much more advanced workflows than are possible through a SharePoint Web application. At the same time, however, the process of creating those workflows is much more complicated. There's no way I'll be able to teach you all of the intricacies of creating workflows with SharePoint Designer in the amount of space that I have to work with, so my goal is to introduce you to the basic principles.

Proper Setup
Before you even start working with the SharePoint Designer, you need to have a list or a document library prepared to which you're going to attach the workflow. With that in mind, open the SharePoint Designer and use the Open Site command on the File menu to open your SharePoint site. When the SharePoint Designer prompts you to open the site, enter the URL of the SharePoint site that you want to add the workflow to.

The next step in the process is to select the New | Workflow commands from the File menu. When you do, you'll be taken to the screen that is shown in Figure 9. As you can see in the figure, the first things you'll do involve providing a name for the new workflow, specifying which list or document library the workflow should be attached to and choosing the start-up options for the workflow.

Figure 9
[Click on image for larger view.]
Figure 9. The Workflow Designer guides you through the workflow-creation process.

After you've entered the required information click Next, and you'll be taken to the Specify Details screen. The screen contains drop-down lists that allow you to specify a condition and an action. For example, suppose that you want to create a workflow that sends an e-mail message to someone when a document is modified by a specific person. To do so, you could select the If Modified by Specific Person option from the Conditions drop-down list, and choose the E-mail This Message option from the Actions drop-down list. You can see what this looks like in Figure 10.

At this point, simply click Finish to create the workflow.

There are a couple of additional things I want to point out. For starters, if you look at Figure 10, you'll notice that the words Specific Person and This Message are hyperlinked. If you click on either of these hyperlinks, you'll have the opportunity to populate the variable. This allows you to specify the person you want to watch for modifications, as well as the message you want to e-mail when those modifications occur. In fact, clicking the This Message link allows you to specify more than just the message itself-you can also provide a recipient, a CC list and the subject line.

Figure 10
[Click on image for larger view.]
Figure 10. You must specify at least one condition and at least one action.

Another thing I want to mention is the option under the Actions button to add an Else If conditional branch. This lets you specify multiple options.

It's important not to confuse multiple options with multiple steps. If you look in the upper right-hand corner of Figure 10, you'll see that we've only created the first step in a workflow. There's an option just below the listing for Step One that allows you to create additional steps.

If you create Else If conditional branching, you're essentially creating additional conditions for the current step, and not additional steps. It's this branching, and the ability to create multiple steps, that allow you to create some truly powerful SharePoint workflows.

Now you know how to create SharePoint workflows through the SharePoint Designer. Keep in mind that the SharePoint Designer allows you to create some very intricate workflows without actually having to write any of the underlying code.

Featured

comments powered by Disqus

Subscribe on YouTube

Upcoming Training Events

0 AM
TechMentor @ Microsoft HQ
August 11-15, 2025