Creating a Custom Approval Workflow for SharePoint Server 2007 Using SharePoint Designer 2007

Summary:  Learn how to use Microsoft Office SharePoint Designer to create codeless workflows for Microsoft Office SharePoint Server 2007 that can be attached to SharePoint lists.

Office Visual How To

Applies to:  2007 Microsoft Office System, Microsoft Office SharePoint Designer 2007, Microsoft Office InfoPath 2007, Microsoft Office SharePoint Server 2007

David Gerhardt, 3Sharp

June 2008

Overview

Microsoft Office SharePoint Designer 2007 enables you to create codeless workflows that you can attach to any SharePoint lists in Microsoft Office SharePoint Server 2007. These workflows can be started automatically when a list item is added or changed, and they can contain conditional logic for associated actions.

Code It

An Office SharePoint Designer 2007 workflow can analyze list item data and then assign tasks accordingly. For example, in an expense report scenario, vice-president (VP) approval might be required if the report total exceeds a certain amount. A workflow created with Office SharePoint Designer 2007 could evaluate the "total" field and then send an e-mail message or assign a SharePoint task to the appropriate approver.

For this scenario, you use the expense report sample template that comes with Microsoft Office InfoPath 2007, and you make a few modifications to capture VP and report status information. Then, after publishing the form template to a SharePoint document library, you create an Office SharePoint Designer 2007 workflow that sends a notification e-mail message either to the employee's manager or a VP, depending on the expense report total.

Adding Nodes to Capture VP Information

Start the expense report sample template in the InfoPath designer, and add nodes that capture the employee's VP information.

To add VP nodes to the form's data source and bind controls to those nodes

  1. In the Design Tasks task pane, click Data Source.

  2. In the Data Source task pane, right-click the expenseReport root node, and then click Add.

  3. In the Add Field or Group dialog box, in the Name box, type VPName, and then click OK.

  4. Repeat the previous two steps to add a VPEmail node.

    Figure 1. Adding VP nodes to the data source

    Adding VP nodes to the data source

  5. In the form view, place the cursor below the Manager Information table, click Table, click Insert, and then click Layout Table, and add a layout table that is similar in structure to the Manager Information table. Adjust the formatting in the layout table accordingly.

    Figure 2. Creating the VP Information layout table

    Creating the VP Information layout table

  6. Separately drag the VPName and VPEmail nodes from the Data Source task pane to the VP Information table, which automatically binds text boxes to those nodes. Adjust the labels in the layout table accordingly.

    Figure 3. Binding text boxes to the new nodes

    Binding text boxes to the new nodes

Adding a Node to Capture Status Information

You must add an approve/reject mechanism to the form template for the approvers. In an advanced scenario, you could add "approve" and "reject" button controls to the form view that update status and subsequently submit the form data. For this simple scenario, you just add a status node to the data source and then bind a drop-down list box to that node.

To add a status node to the form's data source and bind a control to that node

  1. In the Data Source task pane, right-click the expenseReport root node, and then click Add.

  2. In the Add Field or Group dialog box, in the Name box, type status, and then click OK.

  3. Add a row to the layout table at the top of the form view, and place the cursor within that row.

  4. In the Data Source task pane, right-click the status node, and then click Drop-Down List Box. Adjust the formatting in the layout table accordingly.

    Figure 4. Binding a drop-down list box to the new node

    Binding a drop-down list box to the new node

  5. Double-click the Status drop-down list box in the form view.

  6. In the Drop-Down List Box Properties dialog box, click Add.

  7. In the Add Choice dialog box, in the Value box, type Approved, and then click OK.

  8. Repeat the previous two steps to add a Rejected option.

    Figure 5. Adding options for the drop-down list box

    Adding options for the drop-down list box

  9. In the Drop-Down List Box Properties dialog box, click OK.

    Note

    For this simple scenario, the form initiator can identify the expense report status. In a more advanced version of the same scenario, you could add conditional formatting to the form template to disable the Status drop-down list box for new forms.

Promoting Form Fields as SharePoint Columns

For form fields to be used in Office SharePoint Designer 2007 workflow conditions and actions, they must be promoted as SharePoint columns. You can specify promoted fields in the Form Options dialog box or in the InfoPath Publishing Wizard.

To specify promoted fields

  1. Click Tools, and then click Form Options.

  2. In the Form Options dialog box, click the Property Promotion category.

  3. Click Add.

  4. In the Select a Field or Group dialog box, expand the manager group, click the managerEmailAddress node, rename the Column name as needed, and then click OK.

  5. Repeat the previous two steps for the VPEmail, total (items group), and name (employee group) nodes.

    Figure 6. Specifying promoted fields

    Specifying promoted fields

  6. In the Form Options dialog box, click OK.

  7. Save the form template locally.

After you add VP and status nodes and specify certain promoted fields, use the InfoPath Publishing Wizard to publish the form template directly to a document library.

Note

Before using the wizard, you might want to add a data connection that lets users submit form files to the document library where the form is to be published. Click Tools, and then click Data Connections to open the Data Connections dialog box. After adding the submit data connection, you can update the template's submit options by clicking Tools and then clicking Submit Options.

To publish the form template to a SharePoint document library

  1. Click File, and then click Publish.

  2. On the first page of the wizard, click To a SharePoint server with or without InfoPath Forms Services, and then click Next.

  3. On the next page, type the URL of your SharePoint site, and then click Next.

  4. On the next page, click Next.

  5. On the next page, click Create a new document library, and then click Next.

  6. On the next page, type a name for the new document library, and then click Next.

    Figure 7. Naming the new document library

    Naming the new document library

  7. On the next page, click Next.

  8. On the next page, click Publish.

  9. On the last page, click Close.

Defining a New Workflow

After the form template is published to a document library, you can use Office SharePoint Designer 2007 to define a workflow that is attached to that library. In the Workflow Designer, you can select options that enable you to start the workflow automatically or manually. For this scenario, you have the workflow started automatically when a new item is created.

To define a new workflow for the expense report document library

  1. Start Office SharePoint Designer 2007.

  2. Click File, and then click Open Site.

  3. In the Open Site dialog box, in the Site name box, type the URL for the site where the expense report document library resides, and then click Open.

  4. Click File, click New, and then click Workflow.

  5. In the Workflow Designer, in the Give a name to this workflow box, type a name for the workflow.

  6. Click the What SharePoint list should this workflow be attached to list, and click the expense report list option.

  7. Clear the Allow this workflow to be manually started from an item check box.

  8. Select the Automatically start this workflow when a new item is created check box.

    Figure 8. Defining the new workflow

    Defining the new workflow

Specifying Conditional Logic

In the Workflow Designer, you specify the conditions and actions for each step in the workflow. Steps are processed sequentially. Within each step, branches are also processed sequentially. Processing stops in the step when a conditional branch evaluates to "true". For this scenario, you have a single step that contains two branches: one for the employee's manager, and the other for the VP.

To add conditional logic to the workflow

  1. In the Workflow Designer, click Next.

  2. Click Conditions, and then click Compare Expense field.

  3. Click the field link, and then click Report Total.

  4. Click the equals link, and then click is less than.

  5. Click the value link, and type 5000.

  6. Click Actions, and then click Send an Email.

Note

If the Send an Email option does not appear in the Actions list, click More Actions to add it from the Workflow Actions dialog box.

  1. Click the this message link.

  2. In the Define E-mail Message dialog box, click the lookup icon that is located to the right of the To box.

  3. In the Select Users dialog box, double-click Workflow Lookup.

  4. In the Define Workflow Lookup dialog box, click the Field list, click Manager Email Address, and click OK.

  5. In the Select Users dialog box, click OK.

  6. In the Subject box, type a subject.

  7. For the message body, use a combination of static text and the Add Lookup to Body button to create a dynamic message.

    Figure 9. Defining the e-mail message

    Defining the e-mail message

  8. In the Define E-mail Message dialog box, click OK.

  9. Click the Add 'Else If' Conditional Branch link.

  10. Add the logic that will send an e-mail message to the employee's VP if the report total is greater than or equal to $5,000.

    Figure 10. Completing the conditional logic

    Completing the conditional logic

  11. In the Workflow Designer, click Finish.

Read It

Office SharePoint Designer 2007 workflows enable you to create conditional step logic that can be attached to any SharePoint list, without having to write custom code. These workflows can be triggered automatically when new items are added to a list or when items are changed in a list. If you are creating a workflow that is to be used with an InfoPath form, make sure that the correct fields in the form template are promoted as SharePoint columns during the publishing process so that they can be used in workflow conditions and actions.

See It Creating a Custom Approval Workflow

Watch the Video

Video Length: 00:08:21

File Size: 5.77 MB WMV

Explore It