Lab 12: Using SharePoint Server Workflows with InfoPath 2007

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Learn how to start a workflow on an Office InfoPath 2007 form, and then complete tasks that are part of that workflow from within InfoPath. (5 printed pages)

February 2007

Applies to:Microsoft Office InfoPath 2007

Contents

Lab Objectives

After completing this lab, you will know how to do the following:

  • Add a workflow to a form library.

  • Start a workflow from within Office InfoPath 2007.

  • Complete workflow tasks from within InfoPath.

  • Add workflow status and other metadata to an InfoPath form template.

  • Use workflow status in form template business logic.

Lab Setup and Requirements

To complete this lab, you must have the following:

  • Microsoft Office InfoPath 2007

  • Access to a Microsoft Office SharePoint Server 2007 server

    NoteNote

    If you install both applications on the same computer, you can replace <ServerName>, which is a placeholder for the name of your Office SharePoint server in the following steps, with "localhost." Otherwise, replace <ServerName> with the name of your Office SharePoint server.

Scenario

A manager at Contoso Corporation wants employees to get approval for any company travel before they schedule it. To do this, the manager will use a form library in Microsoft Office SharePoint Server 2007, the preconfigured Approval workflow, and the InfoPath Travel Request sample form.

Exercises

Adding a Workflow to a Form Library

The first step will be to create the form library and add the workflow to it.

To create a form library

  1. Start InfoPath.

  2. In the Getting Started dialog box, click Design a Form Template.

  3. Click Customize a Sample.

  4. Double-click Sample - Travel Request.

  5. On the File menu, click Publish.

  6. If you are prompted to save the form, select the Always save the form when publishing check box, and then click OK.

  7. Click Save to save the form to My Documents.

  8. Click To a SharePoint server with or without InfoPath Forms Services, and then click Next.

  9. Type http://<ServerName>/, where <ServerName> is the name of your Office SharePoint server, and then click Next.

  10. Click Document Library, and then click Next.

  11. Click Create a new document library, and then click Next.

  12. In the Name box, type Travel Requests, and then click Next.

  13. Click Next again, and then click Publish.

  14. Select the Open this document library check box, and then click Close.

To add a workflow to a form library

  1. In Internet Explorer, open the form library you created (http://<ServerName>/Travel Requests/).

  2. On the Settings menu, click Form Library Settings.

  3. In the Permissions and Management section, click Workflow settings.

  4. In the Workflow Template list, click Approval.

  5. In the Name box, type Approval.

  6. Click Next.

  7. Review the workflow settings, and then click Next.

  8. Review the initial workflow settings, and click OK.

  9. Click Travel Requests in the navigation link above the title Change Workflow Settings: Travel Requests to return to the form library.

Starting and Completing Workflow Tasks in InfoPath

Use InfoPath menus to begin a workflow associated with the form library, and use the yellow bar below the menus to complete an active workflow.

To start a workflow from within InfoPath

  1. In Internet Explorer, open the form library you created (http://<ServerName>/Travel Requests/).

  2. Click New.

  3. When the form opens in InfoPath, click Save on the File menu.

  4. Click Save again to save the form back to the form library.

  5. On the Tools menu, click Start Workflow.

  6. On the Workflows dialog box, click Start.

  7. In the Approval dialog box (shown in Figure 1), click Approvers.

    Figure 1. Adding approvers in the Approval dialog box

    The Approval dialog to start the workflow

  8. Search for your name, select it, and then click Add.

  9. Review the initial workflow settings, and click Start.

To complete workflow tasks from within InfoPath

  1. In InfoPath, open the form that you saved to the form library.

  2. At the top of the InfoPath form, on the yellow bar labeled Workflow Task, as shown in Figure 2, click Edit this task.

    Figure 2. Editing a task in the Workflow task bar

    The Workflow Task Bar

  3. Click Approve.

  4. Close the form and return to the Office SharePoint Server library.

    The workflow status shows Approved in the Approval column.

Using Workflow Status in Form Template Business Logic

Using the workflow status in the form requires setting up a data connection to retrieve the workflow information from the site. Using the workflow status in business logic enables you to switch to another view based on the workflow status.

To add workflow status and metadata

  1. Return to the Travel Request form template in design mode, either by opening it from the location where you saved it or by switching to the instance of InfoPath that contains the Travel Request form template.

  2. On the Tools menu, click Data Connections.

  3. Click Add.

  4. Click Create a new connection to and Receive Data, and then click Next.

  5. Click SharePoint library or list, and then click Next.

  6. Type http://<ServerName>/, and then click Next.

  7. Select the library that this form template is published to (Travel Requests), and then click Next.

  8. Select the Include data for the active form only check box, and then click Next.

  9. Review the offline settings, and then click Next.

  10. Review the remaining settings, and click Finish.

  11. Click Close to close the Data Connections dialog box.

  12. On the View menu, click Data Source.

  13. In the Data Source task pane, select Travel Requests (Secondary) in the Data source list. Expand dataFields and Travel_Requests in the task pane, as shown in Figure 3.

    NoteNote

    The Approval field is now available to all the business logic features in InfoPath.

    Figure 3. Viewing the Approval field in the Travel Request Data Source

    The Approval Field in the Data Connection

To use workflow status in business logic

  1. The Travel Request form template should be open in design mode. On the View menu, click Manage Views.

  2. In the Views task pane, click Add a New View.

  3. Name the view Approved, and click OK.

  4. Type This travel request has been approved in the new view.

  5. On the Tools menu, click Form Options.

  6. In the Form Options dialog box, click the category Open and Save.

  7. In the Open behavior section, click Rules.

  8. Click Add.

  9. Click Set Condition.

  10. In the first drop-down list, click Select a field or group.

  11. Click Travel Requests (Secondary) in the Data source list.

  12. Expand the data source, click the Approval field, and then click OK.

  13. In the third drop-down list, click Type text.

  14. Type 16, which corresponds to Approved, and then click OK.

  15. Click Add Action.

  16. Click Switch views for the action.

  17. Note that the Approved view is selected, and click OK.

    The completed Rules dialog box should look like Figure 4.

    Figure 4. Completing the Rules dialog box

    The Completed Rule dialog box

  18. Click OK in all remaining dialog boxes.

To test your business logic

  1. Republish the form by clicking Publish on the File menu.

  2. In the Publishing Wizard, continue to click Next through the wizard pages until the Publish button appears.

  3. Click Publish, and then after the form is published, click Close to close the Publishing Wizard.

  4. Browse to the document library, and open the previously completed form, Form1.

    NoteNote

    The view switches because the workflow is Approved.

Conclusion

In these exercises, you learned how to create form libraries that use workflow, how to start a workflow and complete workflow tasks from within InfoPath 2007, and how to create InfoPath form templates that incorporate workflow status into business logic.