Content types can be extended to enhance storage, format and expose content, and extend business processes. This section looks at associating workflows with content types both through the document library administrative user interface and also using SharePoint Designer 2007. It also looks at how you can leverage content types for managing e-mail records and formatting e-mail messages in lists and Web Parts throughout SharePoint Server 2007 sites.
There are three ways to integrate workflow in SharePoint Server 2007:
Through an administrative user interface
With SharePoint Designer 2007
With Visual Studio 2005
This section looks at adding workflows specifically to content types using the SharePoint built-in workflows, through the administrative user interface. It also looks at creating a custom workflow in SharePoint Designer 2007 based on content type.
You can add a workflow to either a site-level content type or a document library-level, or list-level, content type. If you apply a workflow to a global content type, all instances of that content type will include that workflow.
To add a workflow to a document library, or list, content type, complete the following steps:
In this scenario, you are only adding a workflow to the current list instance of the content type.
Go to the document library, in this case the Project document library, and select Document Library Settings.
On the Customize Projects page, browse to the Content Types section and click the content type against which you want to place the workflow.
On the List Content Type page, under the Settings section, select Workflow Settings.
On the Change Workflow Settings page, shown in Figure 15-20, the existing workflows are Approval, Collect Feedback, and Collect Signatures. These workflows are already associated with the global content type, Document, and are included here because this content type is a child of the Document content type. You can choose to edit these existing workflows or create new workflows.
Select Add A Workflow.
There are four built-in, or default, workflows from which to choose and apply to the content type:
Add a name for the content type workflow, configure the rest of the settings, and then click Next.
On the Customize Workflow page, complete the configuration settings, add the users you want to have included in the approval workflow process, and then click OK to return to the Change Workflow Settings For Content Type page. You'll notice the addition of the new workflow you've just created. In this example, a new workflow called A Document Approval has been added to the document library instance of the Project Meetings content type.
Figure 15-20: Changing workflow settings for the content type
The workflow assigned to the content type is unique to that content type; it is not available to the entire document library or to other content types in the same document library.
You can also start the workflow from within the associated Office application. For example, in Word 2007, on the File menu you can click Start Workflow and a dialog box showing all related workflows for that document type will be shown. (See Figure 15-21.) This dialog box includes any workflows specific to that document type, as well as any content types specific to the document library where that document is stored.
Figure 15-21: Start workflow from associated content type template
The obvious advantages of being able to apply both content-type-specific workflows and document-library-level workflows is that you might want to set a general approval workflow for all documents in the document library but only want to apply certain workflows to certain documents. For example, you might want to collect signatures for an expense report, or you might want to place an expiration date (Disposition Approval) on certain types of project documents. Or you might want different users or groups associated with one type of document workflow and not another.
We can configure workflows in SharePoint Designer 2007 using content type properties. SharePoint Designer 2007 allows us to take workflow a step beyond the built-in workflows just demonstrated by including the ability to add steps and conditions.
To design and create a workflow using SharePoint Designer 2007, you will need to have installed the Windows Workflow Foundation on the same machine on which SharePoint Designer 2007 is installed.
To trigger a workflow on a multiple-content-type document library that sends e-mail to a user based on one content type and copy a document based on another content type, complete the following steps:
Open your site in SharePoint Designer 2007.
You need a minimum of Web Designer access to the site to access the workflow settings in SharePoint Designer 2007.
From the File menu, select New and then Workflow.
Define your new workflow, as shown in Figure 15-22. Give the workflow a name, and attach the workflow to a specific list (or document library) in the site. In this case, we've chosen the Projects document library on the Fabrikam site and named the workflow Project Workflow.
When you create a workflow in SharePoint Designer 2007, the workflow is specific to the list (or document library) you define. It is not available to other lists on the site, and it is not uniquely associated with a content type.
Still on the Define Your New Workflow page, under Select Workflow Start Options For Items In Projects, set the workflow to either start manually through end-user intervention only or to start automatically when a condition of the workflow is met. Click Next.
The next screen prompts you for a step name. In SharePoint Designer 2007, you can include one or multiple steps in your workflows.
Optionally, give the step a name and then click Conditions.
From the drop-down list, select Compare Any Data Source.
This results in the condition of:
If value equals value
Click the first highlighted word Value and then click on the fx symbol (or Display Data Binding).
In the Define Workflow Lookup window, leave Source set as Current Item. From the Field drop-down list, select Content Type. Click OK.
Leave the Equals in the condition as Equals.
Click the next highlighted word, Value.
If the document library has multiple content types, they are listed in the drop-down list from Value.
Select the content type from the drop-down list, as shown in Figure 15-23.
Next, select Actions.
From the Actions list, select Send An Email.
Click the highlighted words "This Message."
In the Define E-mail Message window, configure the e-mail settings and click OK.
Back on the Workflow Designer window, click Add Else If Conditional Branch link.
In the new conditional branch, click Conditions and select Compare Any Data Source.
Click the highlighted word Value.
Select the fx symbol.
In the Define Workflow Lookup window, leave Source set as Current Item.
From the Field drop-down list, select Content Type and click OK.
Leave the value of equals as equals.
Click the remaining highlighted word, Value.
Select one of the other content types from the value drop-down list, as shown in Figure 15-24.
Next, while still working in the second conditional branch, click Actions and select Copy List Item.
In the resultant action Copy Item In This List To This List, select the first highlighted this list and choose Current Item.
Select the second highlighted this list, and choose an alternate document library, or list. Your workflow screen should look like Figure 15-25.
Click Finish to save the new workflow back to the destination list (or document library).
Figure 15-22: Defining a workflow
Figure 15-23: Selecting a content type
Figure 15-24: Selecting an additional content type for value
Figure 15-25: Completed workflow
Using the built-in workflows, you can assign a workflow to either a global content type instance or a list, or document library, instance of a content type. Using SharePoint Designer 2007, you can associate a workflow with a specific list, or document library, and you can set conditions and actions based on the content types within that list or document library.
In SharePoint Server 2007, you can configure your lists and document libraries to receive incoming e-mail messages and attachments.
For instructions on how to configure incoming e-mail for SharePoint Server 2007, refer to Chapter 6, "Performing Central Administration and Operations Configuration."
How those e-mail messages are subsequently presented and stored in SharePoint Server 2007 can depend on the default content type of the targeted list or document library. For example, it can depend on whether the fields of your e-mail are exposed as columns, such as the E-mail sender and E-mail body, or whether there is a specific workflow or records policy set against the content type.
You can e-mail directly from your Microsoft Office Outlook client to document libraries, picture libraries, custom lists, announcements, calendars, and discussion boards. Document libraries are limited to Document content types, and lists are limited to List content types. E-mail messages will be presented and stored depending on the content type.
If you e-mail document libraries, or lists, where the default content type includes required columns, then those required columns will not apply to the e-mail and the sender will not be prompted to populate columns before the e-mail is checked in.
If you e-mail a document library, where the default content type is based on the Document content type, the e-mail message is stored as an EML file and any attachments are saved separately in the same document library. Both the e-mail message and attachment are saved with the default content type. For example, in Figure 15-26 an e-mail message has been e-mailed to a document library where the Project Procurement content type is the default content type. The e-mail message is stored as a file.
Figure 15-26: E-mail message stored using the default Document content type
The default content type is that content type which has been set in order as the first content type in a document library configured for multiple content types.
If you open the e-mail file in the document library, the body of the e-mail is launched on a separate page. Viewing the e-mail properties confirms that the e-mail's content type is the Project Procurement content type.
Any received e-mail messages inherit any policies or workflow set against the default content type. For example, your company might have an e-mail retention policy whereby e-mail messages are deleted after a certain period of time. In the Information Management Policy Settings for a content type, you can enable expiration. So you could specify that all e-mail messages over three months old are to be deleted, or you could implement a workflow to alert users of the expiration period and copy e-mail messages to the Web application's record repository.
If you wish to have incoming e-mail properties stored in editable form, such as the title and body of the e-mail, then you can achieve this by configuring and leveraging the Announcement content type for those e-mails, as shown in Figure 15-27. In this case, an e-mail has been e-mailed to the Submitted E-mail Records list in the records repository and includes an Expiration Date.
Figure 15-27: E-mail format in Announcement content type
By default, Team Sites include an Announcements Web Part on the home page. By configuring the associated Announcement list for incoming e-mail and e-mailing those lists, e-mail messages can be dynamically exposed as announcements in the Announcements Web Part.
One point worth mentioning here is the e-mailing capabilities of the SharePoint calendar. You can e-mail meeting requests from your Outlook calendar directly to a calendar in your SharePoint site. The meeting will be created and stored on the SharePoint calendar under the calendar's default content type, Event, as shown in Figure 15-28.
Figure 15-28: E-mail and the Event content type
If you make any changes to an e-mailed meeting on the SharePoint calendar, those changes will be automatically synchronized with the originating meeting planner.
You can also e-mail directly to a Discussion Board, which includes by default two content types, Discussion and Message. The e-mail message will be added as a new discussion thread.
As you can see, you can take advantage of the lists and contents types to both format and add custom actions to incoming e-mail messages in your SharePoint sites. You could also extend e-mail management by adding custom workflows to the content types associated with the document libraries or lists receiving e-mail messages using SharePoint Designer 2007 or Visual Studio 2005.