Creating Custom Workflows

You can create custom OBA workflow solutions for Windows SharePoint Services and for Office SharePoint Server 2007 using either Office SharePoint Designer 2007 or Visual Studio 2008. Both tools provide design templates that help you build workflow solutions. However, each authoring tool provides different capabilities.

Overview of Creating Custom Workflows in SharePoint Designer

Office SharePoint Designer 2007 provides a simple rules-based approach that enables you to create workflow solutions based on preexisting activities and to associate workflows directly to lists or document libraries. This authoring tool allows you to define workflows with no custom code. Office SharePoint Designer also simplifies the deployment process, since workflow markup, rules, and supporting files are stored in a specific document library. For those reasons, it is a tool commonly used by information workers and Web designers. You can use this authoring tool to build simple OBA workflow solutions that automate business processes in your enterprise such as document approval, document review, task management, and more. Figure 7-9 shows how you can create new workflows or open existing ones using Office SharePoint Designer as an authoring tool for workflows.

Creating workflows using Office SharePoint Designer 2007 as an authoring tool

Figure 7-9. Creating workflows using Office SharePoint Designer 2007 as an authoring tool

Office SharePoint Designer 2007 provides a wizard-like designer that enables you to define workflow solutions that use a set of business rules and predefined rules, for example, sending notifications via e-mail. This greatly simplifies the process of building workflows. However, when you are making a technology decision, there are some considerations you should keep in mind if you plan to use Office SharePoint Designer 2007:

  • Workflow association. You can associate workflows to lists or document libraries, but you cannot associate workflows to content types. Once you associate a workflow, you cannot change which list or document library a workflow is attached to. Instead, you must create a new workflow and attach it to the list that you want.

  • Forms support. You can design custom ASP.NET 2.0 forms, but SharePoint Designer does not provide support for InfoPath forms. Something else to consider is that workflows authored from Office SharePoint Designer 2007 only support initiation and task completion forms. This is because workflows designed in SharePoint designer cannot be modified while running. Therefore, you cannot define modification forms. As explained earlier, you associate workflows directly to lists or document libraries, meaning the association process happens in design time. Therefore, you cannot define association forms.

  • Workflow authoring styles. You can create sequential workflows, but SharePoint Designer does not support state machine workflows.

Expense Report Scenario

Imagine that you work for Adventure Works Cycles, a sports store franchise that sells bicycles worldwide. This company has sales representatives that visit different countries to help new franchisees open new sports stores. You are asked to build a simple Expense Reporting OBA workflow solution. In this solution, sales representatives will start by filling out a simple expense report form that provides their name, the expense purpose, the expense total, and their direct manager’s name and e-mail address. When sales representatives submit the expense report, the workflow business rules need to verify that the expense total does not exceed $5,000. If the expense total exceeds $5,000, the workflow will submit an e-mail to the direct manager asking for approval. If the expense total is less than or equal to $5,000 the system will send an e-mail to the accounting department asking it to reimburse the sales representative with the expense total amount. Since this is a simple scenario that needs no coding, you decide to use Office SharePoint Designer 2007 to author this OBA workflow solution.

To create this workflow solution, first create a document library in Office SharePoint Server 2007. For this scenario, you name the document library Expense Reports. You must add an Expense Total column of type number to the document library. Once that is configured, use Office SharePoint Designer 2007 to associate the OBA workflow solution you are creating. Figure 7-10 shows the document library you use for the expense reporting solution.

To create the workflow solution, you open Office SharePoint Designer 2007. Next you select the Open Site option from the File menu to select the SharePoint site where you want to create the workflow. Next, in the File menu, select New and click Workflow. This step will launch the Workflow Designer window, as shown in Figure 7-11.

The Workflow Designer window allows you to configure the name of the workflow. In this case, you will name the workflow ExpenseReport. Site visitors see this name when they view the Workflow pages and Workflow status in the Web browser. The Workflow Designer window enables you to select the SharePoint list or document that you want to use and associates it with the workflow. In this case, you will select the Simple Expense Reporting Demo document library that you created previously. Finally, the Workflow Designer window provides three checkboxes that enable you to select whether you want to:

Microsoft Office SharePoint Server 2007 document library for the expense reporting solution

Figure 7-10. Microsoft Office SharePoint Server 2007 document library for the expense reporting solution

The Workflow Designer window in Office SharePoint Server 2007

Figure 7-11. The Workflow Designer window in Office SharePoint Server 2007

  • Allow the workflow to be started manually from an item.

  • Automatically start the workflow when a new item is created.

  • Automatically start the workflow whenever an item is changed.

For the expense reporting solution, you must select the first two checkboxes, as shown in Figure 7-11.

The Workflow Designer also provides an Initiation button that enables you to define the workflow parameters to collect data from participants who manually start workflows. In this case, you can define parameter values for the employee name, the expense purpose, the expense total, the manager’s name, and the manager’s e-mail address. Figure 7-12 shows the workflow initiation parameters for the expense reporting workflow scenario.

Workflow initiation parameters for the Expense reporting workflow scenario

Figure 7-12. Workflow initiation parameters for the Expense reporting workflow scenario

Once you are done defining the workflow initiation parameters, you can define the set of business rules for the workflow. The requirements of the OBA workflow solution define business rules that are specific for this scenario. We explained earlier that when sales representatives submit an expense report, the workflow business rules need to verify that the expense total does not exceed $5,000. If the expense total exceeds $5,000, the workflow submits an e-mail to the direct manager asking for approval. If the expense total is less than or equal to $5,000 the system sends an e-mail to the accounting department asking it to reimburse the sales representative with the expense total amount. The Workflow Designer window enables you to define business rules by using a set of predefined conditions that apply to your scenario. You can compare fields in a current list and perform actions based on satisfied conditions. For this solution, you need to define an if-then-else condition to compare if the expense total field is greater than $5,000. If this condition is satisfied, the manager will receive an e-mail notification, else the accounting department will receive an e-mail notification. Figure 7-13 shows the business rules definition process.

Once you click the Finish button in the Workflow Designer window, the workflow is saved and attached to the list you specified. Each time a sales representative submits an expense report, Office SharePoint Server 2007 launches a workflow instance and validates the business rules.

Business rules definition process

Figure 7-13. Business rules definition process

Workflow Project Templates in Visual Studio Tools for Office

At the beginning of this chapter, we discussed the challenges and opportunities that modern enterprises currently face when creating solutions that better integrate back-end systems and LOB information with commonly used information worker applications. Today, developers have in their hands a new set of developer tools and technologies that simplify the process of building solutions that connect back-end systems with Office client applications. As discussed in Chapter 4, you can define Software + Services (S+S) to build services that connect to LOB systems. The Office platform simplifies the integration between software services and software to simplify the consumption of these services.

In addition, Microsoft provides Visual Studio 2008 and Visual Studio Tools for Office (VSTO) as authoring tools that greatly simplify the development of elaborate OBA workflow solutions. Visual Studio Tools for Office 3.0 is a component that ships with Visual Studio 2008. Chapter 2 explains how you can build custom smart client solutions for your OBAs using VSTO. In addition, VSTO has an improved set of workflow project templates that support Rapid Application Development (RAD) of custom workflow SharePoint Solutions. Together, Visual Studio 2008 and VSTO provide tools that help you create custom workflow templates that manage the life cycle of documents and list items in a SharePoint Web site. Some of these tools include a graphic designer, a complete set of drag-and-drop activity controls, and the necessary assembly references you need to build a workflow solution. VSTO also includes the New Office SharePoint Workflow wizard, which greatly simplifies the configuration process and steps for creating workflow templates in Visual Studio. Figure 7-14 shows the different Visual Studio installed templates for Office 2007. These templates include a SharePoint Sequential Workflow template and a SharePoint State Machine Workflow template.

SharePoint Sequential Workflow and SharePoint State Machine Workflow templates in Visual Studio 2008

Figure 7-14. SharePoint Sequential Workflow and SharePoint State Machine Workflow templates in Visual Studio 2008

Workflow solutions in Visual Studio 2008 allow a greater level of customization than workflow solutions authored in Office SharePoint Designer 2007. Not only can you use a predefined set of activities, but you can create new activities for use as workflow components. Additionally you can define forms for association, initiation, modification, and task editing using either ASP.NET 2.0 Web forms or InfoPath forms. Visual Studio 2008 provides support to design, code, and publish the forms to the server.

As explained earlier, you can use Visual Studio 2008 to build workflow solutions for either Windows SharePoint Services or Office SharePoint Server 2007. Once compiled, workflow solutions are packaged as templates that can later be associated to different lists, document libraries, and content types. This provides another great advantage with respect to workflow solutions built with Office SharePoint Designer 2007. Another great advantage is that Visual Studio 2008 allows you to build workflow solutions and custom activities that you can reuse in different workflow solutions. You can, for example, create a custom activity that adds workflow steps as tasks in Outlook.

Finally, since you are using Visual Studio 2008, you are given all the advantages provided by Visual Studio as an authoring tool for developer solutions. Some of these advantages include the use of code-behind files, intellisense, debugging, use of the different workflow object models that enable workflow extensibility, and support for building custom classes and Web services that can bring LOB data.

Note

Note

You can build workflow solutions with Visual Studio 2005 using the Visual Studio 2005 Designer for Windows Workflow Foundation add-in. This add-in is available as part of the Microsoft Windows Workflow Foundation Runtime Components and Visual Studio 2005 Extensions for Windows Workflow Foundation. However, Visual Studio 2008 reduces complexity and greatly speeds development of SharePoint workflow OBA solutions. For that reason, this book chapter focuses on showing the latest workflow enhancements added to Visual Studio 2008 and Visual Studio Tools for Office. For more information about the Visual Studio 2005 Designer for Windows Workflow Foundation, visit http://www.microsoft.com/downloads/details.aspx?familyid=5c080096-f3a0-4ce4-8830-1489d0215877&displaylang=en. For more information about the Visual Studio 2005 extensions for the .NET Framework 3.0 (Windows Workflow Foundation), visit http://www.microsoft.com/downloads/details.aspx?familyid=5D61409E-1FA3-48CF-8023-E8F38E709BA6&displaylang=en.

Visual Studio 2008 offers a basic activity library (BAL) that provides a set of predefined activities you can use to define a workflow template. An activity is a step or task that performs an action in a workflow—for example, sending an e-mail, adding tasks to Outlook 2007, adding items to SharePoint lists, or connecting to an LOB database to retrieve or save information. While designing workflows, you can use the toolbox in Visual Studio 2008 to drag and drop activities to your workflow solution. Activities are built as classes, and therefore, have properties, events, and methods as any other class. You can use activities from either the Windows Workflow tab or the SharePoint Workflow tab. The Windows Workflow tab provides a set of activities provided by the Windows Workflow Foundation, while the SharePoint Workflow tab provides a set of activities that are specific to Windows SharePoint Services and Office SharePoint Server 2007. Some of these activities include OnWorkflowActivated, CreateTask, DeleteTask, SendEmail, and CompleteTask. Additionally, you can build your own custom activities by creating a class that implements the SequentialWorkflowActivity class if you need a sequential activity or the StateMachineWorkflowActivity if you need a state machine activity. Figure 7-15 shows the Windows Workflow 3.0 and the SharePoint Workflow toolbox tabs in Visual Studio 2008.

Windows Workflow 3.0 and the SharePoint Workflow toolbox tabs in Visual Studio 2008

Figure 7-15. Windows Workflow 3.0 and the SharePoint Workflow toolbox tabs in Visual Studio 2008

For more information about creating custom activities, visit http://msdn2.microsoft.com/en-us/library/ms734563(VS.90).aspx.

The next section of this chapter provides a high-level overview of and guidance for creating sequential workflows and state machine workflows using Visual Studio 2008 as an authoring tool.

Sequential Workflows

As we explained earlier, sequential workflows execute activities in a predefined pattern and represent a workflow as a procession of steps that must be executed in order until the last activity is completed. As shown in Figure 7-14 Visual Studio 2008 has a new SharePoint Sequential Workflow project template that provides a graphic workflow designer, a complete set of drag-and-drop activity controls, and the necessary assembly references you need to build a sequential workflow solution.

Previously, we talked about a scenario in which you have to build a vacation leave notification system for your company. When an employee saves a document, the direct manager receives an e-mail notification to let her know that she has to approve vacation time for an employee. If the manager approves the document, the system sends an e-mail to the employee. If the manager rejects the vacation request, the employee receives an e-mail with comments from the manager. In either case, the workflow reaches an end and terminates the execution. Because you want to add more customization and use debugging, you decide to use Visual Studio 2008.

To create this solution, you start by creating a simple "Vacation and Time Off" document library. You should add the following four columns to the document library, as shown in Figure 7-16:

  • Employee Name: Create this column as Single line of text.

  • Manager’s Name: Create this column as Single line of text.

  • Planned days off: Create this column as Number.

  • Notes: Create this column as Multiple line of text.

Workflow participants will use this document library to store vacation approval forms. Next, in Visual Studio 2008, you start by opening the New Project dialog box and selecting the SharePoint 2007 Sequential Workflow project located under the Office node. In the name box, you type OBAVacationApprovalDemo. This last step opens the New Office SharePoint Workflow wizard, as shown in Figure 7-17.

The next window prompts for a workflow name and a site for debugging the page. Click Next to accept the default settings. The next step requires that you select the document library, task list, and history list you want to use when debugging. In this case, you accept the default settings. The last step of the wizard requires you to define the conditions for how your workflow is started. Visual Studio 2008 allows you to automatically associate a workflow to a document library or list. Additionally, you can choose to handle the association step manually. In this case, you will associate the workflow with the "Vacation and Time Off" document library you created previously. Finally, the wizard asks for the conditions for how your workflow is started. In this case, you choose "Manually by users" and "When an item is created."

"Vacation and Time Off" document library

Figure 7-16. "Vacation and Time Off" document library

New Office SharePoint Workflow wizard

Figure 7-17. New Office SharePoint Workflow wizard

Next, you open the Windows Workflow activities and the SharePoint Workflow activities in the toolbox to drag and drop activities to the Visual Studio 2008 design surface. Visual Studio 2008 enables you to create workflow diagrams just as you can create flowchart diagrams using Visio 2007. Figure 7-18 shows a completed sequential workflow diagram for the vacation leave notification system.

Sequential workflow diagram for the vacation leave notification system

Figure 7-18. Sequential workflow diagram for the vacation leave notification system

You can double-click each activity to customize code behind just as you can double-click buttons on Windows forms solutions to add custom code. You can also define properties for each activity using the Properties window in Visual Studio 2008. Example 7-3 shows the contents of the OBAVacationApprovalDemo sequential workflow class.

Example 7-3. OBAVacationApplicationDemo sequential workflow class

[C#]
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Workflow;
using Microsoft.SharePoint.WorkflowActions;
using Microsoft.Office.Workflow.Utility;

namespace OBAVacationApprovalDemo {
   public sealed partial class Workflow1 : SequentialWorkflowActivity {

      private bool _taskCompleted = false;

      public Workflow1() {
         InitializeComponent();
      }

      public Guid workflowId = default(System.Guid);
      public SPWorkflowActivationProperties workflowProperties = new
      SPWorkflowActivationProperties();
      public static DependencyProperty approveTaskIdProperty =
      DependencyProperty.Register("approveTaskId", typeof(System.Guid),
      typeof(OBAVacationApprovalDemo.Workflow1));
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
      [BrowsableAttribute(true)]
      [CategoryAttribute("Misc")]
      public Guid approveTaskId {
         get {
            return
((System.Guid)(base.GetValue(OBAVacationApprovalDemo.Workflow1.approveTaskIdProperty)));
         }
         set {
            base.SetValue(OBAVacationApprovalDemo.Workflow1.approveTaskIdProperty, value);
         }
      }

      public static DependencyProperty approveTaskPropertiesProperty =
      DependencyProperty.Register("approveTaskProperties",
      typeof(Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties),
      typeof(OBAVacationApprovalDemo.Workflow1));
   [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
      [BrowsableAttribute(true)]
      [CategoryAttribute("Misc")]
      public SPWorkflowTaskProperties approveTaskProperties {
         get {
            return
((Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties)(base.GetValue(OBAVacationApprovalD
emo.Workflow1.approveTaskPropertiesProperty)));
         }
         set {
base.SetValue(OBAVacationApprovalDemo.Workflow1.approveTaskPropertiesProperty, value);
         }
      }

      private void approveTaskCreation(object sender, EventArgs e) {
         try {
            approveTaskId = Guid.NewGuid();
            approveTaskProperties = new
               Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();
            approveTaskProperties.AssignedTo =
               System.Threading.Thread.CurrentPrincipal.Identity.Name;
            approveTaskProperties.Title = "Vacation and Time off Workflow Task";
            approveTaskProperties.Description = String.Format(
               "This is a vacation and time off request " +
               "submitted by {0} [Employee Name] to {1} [Manager's Name]. " +
               "The employee is planning to take {2} days off.",
CustomFieldValue("Employee Name"),
                    CustomFieldValue("Manager's Name"),
                    CustomFieldValue("Planned days off"));
                 approveTaskProperties.PercentComplete = (float)0.0;
                 approveTaskProperties.StartDate = DateTime.Now;
                 approveTaskProperties.DueDate = DateTime.Now.AddDays(10);
                 approveTaskProperties.EmailBody = "Your vacation and time off request
                                                   was approved by your manager.";
                 approveTaskProperties.SendEmailNotification = true;
              }
              catch (Exception ex) {
                 throw (new Exception("Unable to initialize workflow task.", ex));
              }
           }
           private string CustomFieldValue(string fieldName) {
              object item = this.workflowProperties.Item[fieldName];
              string s = this.workflowProperties.Item.Fields[fieldName]
                         .GetFieldValueAsText(item);
              if (s != null) {
                 return s;
              }
              else {
                 return String.Empty;
              }
           }
              private void approveTaskNotCompleted(object sender, ConditionalEventArgs e){
              e.Result = !_taskCompleted;
           }

              public static DependencyProperty afterApproveTaskPropertyChangeProperty =
              DependencyProperty.Register("afterApproveTaskPropertyChange",
              typeof(Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties),
              typeof(OBAVacationApprovalDemo.Workflow1));
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
            [BrowsableAttribute(true)]
            [CategoryAttribute("Misc")]
            public SPWorkflowTaskProperties afterApproveTaskPropertyChange {
               get {
                  return
((Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties)(base.GetValue(OBAVacationApprovalD
emo.Workflow1.afterApproveTaskPropertyChangeProperty)));
              }
              set
{base.SetValue(OBAVacationApprovalDemo.Workflow1.afterApproveTaskPropertyChangeProperty,
value);
              }
           }

           private void onTaskChanged1_Invoked(object sender, ExternalDataEventArgs e) {
              if (afterApproveTaskPropertyChange.PercentComplete == 1.0) {
                 _taskCompleted = true;
              }
           }
        }
}

Once you are done writing code for the vacation leave notification system, you can test the solution by using the Visual Studio debugger. When you debug the solution, Visual Studio deploys the solution to a SharePoint site and it adds the workflow template to a library or list. You can start an instance of the workflow template to test the solution while using standard debugging tools that help you debug your code as you would do with any other Visual Studio solution.

State Machine Workflows

As we explained earlier, state machine workflows respond to external events as they occur and represent a group of states, transitions, and events, which trigger transitions between these states. As shown in Figure 7-14 Visual Studio 2008 also provides a new SharePoint State Machine Workflow project template that provides a graphic workflow designer, a complete set of drag-and-drop activity controls, and the assembly references you need to build a state machine workflow solution.

To create state machine in Visual Studio 2008, start by creating a document library or list that you want to use for a custom solution. Next, in Visual Studio 2008, open the New Project dialog box and select the SharePoint 2007 State Machine Workflow project located under the Office node. In the name box, type the name of your solution. This last step opens the New Office SharePoint Workflow wizard, as shown in Figure 7-16.

The design, development, and debugging of state machine workflows is almost identical to that of sequential workflows. As mentioned before, the only difference is that state machine workflows are event-driven, and therefore, you can create event-driven workflow solutions. Figure 7-19 shows a state machine workflow diagram for the article publishing workflow application scenario we discussed earlier.

State machine workflow for document approval

Figure 7-19. State machine workflow for document approval

Deployment

Visual Studio 2008 simplifies the deployment process by providing a deployment wizard that helps you create a workflow template package that you can use to deploy in different servers. Additionally, when you debug a workflow solution, Visual Studio 2008 deploys the workflow template and required configuration files to the SharePoint development site you used to create your solution. However, if you want to deploy the workflow template to a different server, you must perform additional deployment and configuration steps.

You can create a feature package to encapsulate a workflow solution and deploy it to different servers. A feature package is a CAB file with a .wsp file-name extension that contains the following files:

  • Feature.xml. XML-based file that contains a manifest listing the contents of a workflow solution. It provides high-level information, including the title, description, version, and scope of the workflow. Example 7-4 shows a sample feature.xml file for the OBAVacationApprovalDemo solution.

Example 7-4. Sample feature.xml file for the OBAVacationApprovalDemo solution class

[XML]
<?xml version="1.0" encoding="utf-8" ?>
<Feature Id="cf5c48e7-3428-4982-a039-898cbff616c2"
   Title="OBAVacationApprovalDemo feature"
   Description="Vacation and Time Off Approval Feature"
   Version="12.0.0.0"
   Scope="Site"
   ReceiverAssembly="Microsoft.Office.Workflow.Feature, Version=12.0.0.0,
Culture=neutral, PublicKeyToken=71e9bce111e9429c"
   ReceiverClass="Microsoft.Office.Workflow.Feature.WorkflowFeatureReceiver"
   xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
   <ElementManifest Location="workflow.xml" />
</ElementManifests>
   <Properties>
   <Property Key="GloballyAvailable" Value="true" />
   <!-- Value for RegisterForms key indicates the path to the forms relative to feature file
   location -->
   <!-- if you don't have forms, use *.xsn -->
   <Property Key="RegisterForms" Value="*.xsn" />
 </Properties>
</Feature>
  • Workflow.xmlXML-based file that specifies details about the workflow assembly, metadata, and the custom forms (InfoPath forms or ASP.NET Web forms) needed for the workflow. Example 7-5 shows a sample workflow.xml file for the OBAVacationApprovalDemo solution.

Example 7-5. Sample workflow.xml file for the OBAVacationApprovalDemo solution

[XML]
<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Workflow
   Name="OBAVacationApprovalDemo"
   Description="Vacation and Time Off Approval Workflow"
   Id="36cc9d57-d857-42ea-ad90-e461d58203ac"
   CodeBesideClass="OBAVacationApprovalDemo.Workflow1"
   CodeBesideAssembly="OBAVacationApprovalDemo, Version=1.0.0.0, Culture=neutral,
   PublicKeyToken=6f9ec6d2f579b3c8">
   <Categories/>
   <MetaData>
      <StatusPageUrl>_layouts/WrkStat.aspx</StatusPageUrl>
   </MetaData>
 </Workflow>
</Elements>
  • Compiled assembly. The feature package installs a compiled workflow assembly into the Global Assembly Cache (GAC). We recommend that you sign the assembly using a strong key before you deploy the workflow solution to the server.

  • Custom forms. You must include custom forms needed for the workflow. If the workflow solution uses ASP.NET Web forms, the feature package must provide instructions to deploy the forms to the Layouts folder of the server that will run the workflow solution. On the other hand, if the workflow solution uses InfoPath forms, the feature package must provide instructions to deploy the forms to the Features folder of the server that will run the workflow solution shown in Example 7-7.

Note

Note

You can install InfoPath forms automatically to the server if you define the forms using the element of the feature.xml file.

Building a Feature Package

To build a feature package you start by defining the solution files and the destination directory of all workflow solutions that must be deployed to the front-end Web server. The previous configuration and installation instructions must be defined using a manifest.xml file and a CAB file.

  • Manifest.xml. XML-based file used as a header file that defines the files that must be deployed to a front-end Web server. Example 7-6 shows a sample manifest.xml file used for the OBAVacationApprovalDemo solution.

Example 7-6. Sample manifest.xml file used for the OBAVacationApprovalDemo solution

[XML]
<?xml version="1.0" encoding="utf-8"?>
<Solution SolutionId="36cc9d57-d857-42ea-ad90-e461d58203ac"
                    xmlns="http://schemas.microsoft.com/sharepoint/">
   <FeatureManifests>
      <FeatureManifest Location="OBAVacationApprovalDemofeature.xml"/>
   </FeatureManifests>
   <Assemblies>
      <Assembly DeploymentTarget="GlobalAssemblyCache"
                                Location="OBAVacationApprovalDemo.dll"/>
   </Assemblies>
</Solution>
  • Solution.ddf file. CAB file that specifies which files to include in the output CAB file. Example 7-7 shows a sample solution.ddf file used for the OBAVacationApprovalDemo solution.

Example 7-7. Sample solution.ddf file used for the OBAVacationApprovalDemo solution

.OPTION EXPLICIT
.Set CabinetNameTemplate=OBAVacationApprovalDemo.wsp
.Set DiskDirectoryTemplate=CDROM
.Set CompressionType=MSZIP
.Set UniqueFiles="ON"
.Set Cabinet=on
.Set DiskDirectory1=OBAVacationApprovalDemo

Solutionmanifest.xml manifest.xml

.Set DestinationDir=OBAVacationApprovalDemo
OBAVacationApprovalDemoFeature.xml
OBAVacationApprovalDemoworkflow.xml
OBAVacationApprovalDemoindebugOBAVacationApprovalDemo.dll

Once you create the previous feature package files, you can create a .wsp package file using the makecab.exe command-line utility, as shown in Example 7-8.

Example 7-8. Create a .wsp package file using the makecab.exe command-line utility.

makecab /f Solutionsolution.ddf

Once you create the feature package, you use the stsadm.exe command-line tool to install and activate the workflow solution. Example 7-9 shows how to install a feature using the stsadm command-line tool.

Example 7-9. Use the stsadm.exe command-line tool to install the workflow solution.

stsadm –o installfeature –filename <path of the Feature.xml file relative to the
12TEMPLATEFEATURES folder >

Example 7-10 shows how to activate a feature using the stsadm command-line tool.

Example 7-10. Use the stsadm.exe command-line tool to activate the workflow solution.

stsadm –o activatefeature –name < folder in FEATURES directory containing the Feature
.xml file > -url http://Server/Site/Subsite

It is recommended that a server administrator deploys the workflow solution to a front-end Web server. Once the workflow solution is installed and activated, a site administrator must associate workflows with lists, document libraries, or content types.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset