Design a form to respond to a workflow status

You can design Microsoft Office InfoPath forms to display specific data that corresponds to the current status of a workflow. You do this by designing a form template to use rules that initiate an action in its forms based on the status of the workflow. This can streamline the processes that people use to fill out forms.

This article describes how to design an expense report form template to automatically display different views of the form template, depending on the status of an associated Approval workflow. For example, before the workflow is started, the form will display an Expenses view that contains a repeating table where users can enter expenses. When the workflow status is In Progress, the form will display an Expense Summary view that shows the total expenses in each category. When the workflow status is Completed, the form will display the Completed view, which includes details on estimated reimbursement times.

To enable forms to respond to workflow statuses, you must perform tasks on the Microsoft Office SharePoint Server 2007 site or Windows SharePoint Services 3.0 site, where the forms are located, and tasks in InfoPath. On the SharePoint site you must create a workflow and a site content type, and in InfoPath you must add a data connection to a form template, create a rule, and publish the form template.

Note: This article uses an example scenario in which a form template is published as a site content type. You can also publish a form template to a shared network location or create a new document library when you publish a form template to a SharePoint site. Find more information about publishing form templates in the See Also section.

In this article

Introduction to using workflows with InfoPath forms

Compatibility considerations

Before you begin

Step 1: Add an Approval workflow to a library

Step 2: Add a data connection to a form template

Step 3: Add a rule to a form template to display a specific view

Step 4: Publish a form template as a site content type

Step 5: Add a content type to a document library

Introduction to using workflows with InfoPath forms

Workflows help people collaborate on documents and manage project tasks by implementing specific business processes on documents and items in a Microsoft Office SharePoint Server 2007 site or Windows SharePoint Services 3.0 site. Workflows help organizations adhere to consistent business processes, and they also improve organizational efficiency and productivity by managing the tasks and steps involved in specific business processes. This lets the people who perform these tasks concentrate on performing the work rather than managing the workflow.

You can enable an InfoPath form to display specific data that corresponds to the current status of a workflow. You do this by designing a form template to use rules that initiate an action in the form based on the status of the workflow. This can streamline the processes that people use to fill out forms. For example, you can enable a form to display a read-only view when the status for a workflow is Complete and, therefore, the data in the form should not be changed.

Workflows must be added to a SharePoint list, library, or content type to make them available for use on InfoPath form templates. The available workflows for a site also vary depending on the type of site and whether custom workflows were created by using Microsoft Office SharePoint Designer 2007.

This article uses the Approval workflow to illustrate how workflows can be used with InfoPath form templates. The Approval workflow routes an InfoPath form that is saved to a library to a group of people for approval. By default, the Approval workflow is associated with the Document content type and is automatically available in document or form libraries.

Each workflow is defined by distinct statuses with descriptive names, such as In Progress. The names for statuses vary according to the type of workflow. For example, an Approval workflow — which is available on servers running Microsoft Office SharePoint Server 2007 — includes a status for In Progress, Canceled, and Completed. The statuses of a Three-state Workflow — which is available in Windows SharePoint Services 3.0 — can be defined by the person who adds the workflow to a library or list, whereas other workflows use standard statuses such as the In Progress status noted previously. Although the descriptive name is visible to the user, workflow statuses are represented programmatically by numeric values. To design a form template to respond to a specific workflow status, you must know the numeric value for the workflow status that you want to use. This is because InfoPath uses the numeric value of the workflow to initiate an action, such as switching views.

As noted earlier, you can enable an InfoPath form template to display specific data that corresponds to the current status of a workflow. Although this article describes how to enable an expense report form template to automatically display a specific view depending on its status in the workflow, you can also customize the workflow by adding additional actions. For example, instead of enabling forms to display a specific view, you can enable them to display a dialog box message that shows instructions. And instead of using an Approval workflow, you can use the Three-state workflow.

Note: If you enable actions other than those described in this article, you may need to perform additional steps to help ensure that your form template works correctly with the workflow that you use.

Top of Page

Compatibility considerations

If you plan to create a browser-compatible form template, keep in mind that the document action bar, which is visible when filling out forms in Microsoft Office documents, including InfoPath forms, is not visible in browser-compatible form templates that users fill out in a Web browser. However, you can still use browser-based forms with workflows. To change the workflow status for such forms, workflow participants can use the document library settings. Find more information about changing workflow settings by using SharePoint sites in the See Also section.

Top of Page

Before you begin

Ensure the following before performing the tasks in this article:

  • Contact the farm administrator to confirm that the Approval workflows is installed and enabled for the SharePoint site that you want to use.

  • Ensure that you have at least a Design permission level for the SharePoint site. This permission level is necessary to publish a form template and to create a workflow.

  • Create a form template with two or more views, and customize each view to display the type of data that is appropriate for each workflow status. For example, for the view that you want to appear when the workflow is completed, you can set the controls in that view to read-only.

  • Create a document or form library, and make sure that the library is set up to allow multiple content types.

Top of Page

Step 1: Add an Approval workflow to a library

This scenario focuses on the Approval workflow, but you can use another workflow type if you want. If you use another workflow type, the options for that workflow may differ from those described in this article.

  1. Open the library to which you want to add a workflow.

  2. On the Settings menu, click the settings for the type of library that you are opening.

    For example, in a document library, click Document Library Settings.

  3. Under Permissions and Management, click Workflow settings.

  4. Click Add a workflow.

  5. On the Add a Workflow page, in the Workflow section, click Approval.

  6. In the Name section, type a unique name for the workflow.

    1. In the Task List section, specify a tasks list to use with this workflow.

      Notes: 

      • You can use the default Tasks list or you can create a new one. If you use the default Tasks list, workflow participants will be able to find and view their workflow tasks easily by using the My Tasks view of the Tasks list.

      • If the tasks for this workflow will reveal sensitive or confidential data that you want to keep separate from the general Tasks list, you should create a new tasks list.

      • If your organization will have numerous workflows or if workflows will involve numerous tasks, you should create a new tasks list. In this instance, you might want to create tasks lists for each workflow.

  7. In the History List section, select a history list to use with this workflow. The history list displays all of the events that occur during each instance of the workflow.

    You can use the default History list or you can create a new one. If your organization will have numerous workflows, you can create a separate history list for each workflow.

  8. To allow the workflow to be started manually, select the Allow this workflow to be manually started by an authenticated user with Edit Items Permissions check box in the Start Options section.

  9. To require additional permissions to start the workflow, select the Require Manage Lists Permissions to start the workflow check box.

  10. Specify any other options that you want, including when you want the workflow to start, and then click Next.

  11. On the Customize Workflow page, specify the options that you want, including how tasks are routed, the default workflow start values, and how the workflow is completed, and then click OK.

    Select options in any of the following sections. You are not required to specify options in every section:

    Workflow Tasks

    To

    Do this

    Assign tasks to all participants at once (parallel workflow)

    Select All participants simultaneously (parallel).

    Assign tasks to one participant at a time, requiring that one participate complete a task before the next participant receives a task (serial workflow)

    Select One participant at a time (serial).

    Allow workflow participants to reassign their tasks to other people

    Select the Reassign the task to another person check box.

    Allow workflow participants to request a change to the document or item. The change must be approved before the task is completed.

    Select the Request a change before completing the task check box.

    Default Workflow Start Values

    To

    Do this

    Specify a default list of participants for all instances of this workflow

    Type the names of the participants who you want to include when the workflow starts, or click Approvers and then select people and groups from the directory service.

    Notes: 

    • Separate names with semicolons.

    • If you set up this workflow as a serial workflow, add the names of the workflow participants in the order in which you want the tasks to be assigned.

    Assign a single task to groups, instead of assigning individual tasks for every group member

    Select the Assign a single task to each group entered (Do not expand groups) check box.

    Allow people who start the workflow to change or add participants

    Select the Allow changes to the participant list when this workflow is started check box.

    Specify a default message that appears with each task

    Type a message or instructions in the text box.

    Specify a due date for parallel workflows

    Enter a date under Tasks are due by (parallel).

    Specify how long serial workflow participants have to complete workflow tasks

    Under Give each person the following amount of time to finish their task (serial), type a number, and then select Day(s) or Week(s) as the increment of time.

    Specify a list of people who should receive alerts (not task assignments) when the workflow is started

    Under Notify Others, type the names of the people you want to be notified, or click CC and select people and groups from the directory service.

    Note: Separate names with semicolons.

    Complete the Workflow

    To

    Do this

    Specify that a parallel workflow is complete when a specific number of participants complete their tasks

    Select the Following number of tasks are finished check box, and then type a number.

    Specify that a workflow is complete when the document or item is rejected

    Select the Document is rejected check box.

    Specify that a workflow is complete when the document or item is changed

    Select the Document is changed check box.

    Post-completion Workflow Activities

    To

    Do this

    Update the approval status for a document or item after the workflow is complete

    Select the Update the approval status (use this workflow to control content approval) check box.

    Notes: 

    • If you are using the Approval workflow to manage content approval for a library, and you selected the Start this workflow to approve publishing a major version of an item check box on the Add a Workflow page, this check box is selected by default.

    • If you did not select the Start this workflow to approve publishing a major version of an item check box on the Add a Workflow page because you do not want this workflow to be the default content approval workflow for a library, you can select this check box to make this workflow a secondary content approval workflow that specific users can start manually.

Top of Page

Step 2: Add a data connection to a form template

The following procedure explains how to add a secondary data connection that queries the workflow status of the workflow that you added in Step 1. This secondary data connection provides the data that enables rules in the form to switch views according to the status of the workflow.

  1. In InfoPath, on the Tools menu, click Data Connections.

  2. In the Data Connections dialog box, click Add.

  3. In the Data Connection Wizard, click Create a new connection to, click Receive data, and then click Next.

  4. On the next page of the wizard, click SharePoint library or list, and then click Next.

  5. On the next page of the wizard, type the URL of the SharePoint site.

  6. In the Select a list or library list, click the name of the document library where you added the Approval workflow in Step 1, and then click Next.

  7. On the next page of the wizard, in the Select fields list, select the check box next to the name of the field that matches the workflow name.

    The name of the field might not match the workflow name exactly. If the field name begins with a special character other than an underscore or a letter, the name of the workflow will be customized in the list.

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

  9. Clear the Store a copy of the data in the form template check box, and then click Next.

  10. On the next page of the wizard, in the Enter a name for this data connection box, type a descriptive name for this secondary data connection. This name is what appears in the Data source list in the Data source task pane.

  11. To run the query automatically, whenever the form is opened by a user, select the Automatically retrieve data when form is opened check box.

  12. On the last page of the wizard, click Finish.

  13. In the Data Connections dialog box, click Close.

Top of Page

Step 3: Add a rule to a form template to display a specific view

When you design a form template, you can use rules to automatically display a dialog box, set a field's value, query or submit form data to a data connection, switch views, or open or close a form in response to certain events and conditions. The events can include a change to a particular field or group in the data source, the click of a button, the insertion of a repeating section or row in a repeating table, or the opening or submission of a form. The conditions can include calculations, XPath expressions, and user roles. The conditions can also include whether the value of a field is blank, is within a specified range, equals the value of another field, or starts with or contains certain characters.

In this case, you will create a rule to switch views based on the workflow status.

  1. On the Tools menu, click Form Options.

  2. In the Category list, click Open and Save.

  3. Under Open behavior, click Rules.

  4. In the Rules for Opening Forms dialog box, click Add.

  5. In the Name box, type a name for the rule.

    For example, type Switch Views.

  6. To specify a condition when the rule should run, click Set Condition.

  7. Under Apply the rule when this condition is true, in the first box, click Select a field or group.

  8. In the Data Source list, click the name of the secondary data source that you added in Step 2, and then click OK.

  9. Click the name of the field that corresponds to the workflow status.

    You may need to expand the folders in the window until you see the field that you want.

  10. In the Condition dialog box, in the second list, click is equal to.

  11. In the third list, click Type a number, and then type the value that corresponds to the workflow status.

    For example, for a view that displays when the workflow is completed, type 5.

    Numeric values for workflow statuses in the Approval workflow

    Status

    Numeric value

    In Progress

    2

    Completed

    5

    Canceled

    15

    Approved

    16

    Rejected

    17

    Notes: 

    • The numeric values for statuses in other workflows may differ.

    • The value of the workflow status in InfoPath is read-only. This means that you can't design a form template so that a user can manually change the status of the workflow by entering a value into a control on the form itself.

  12. Click OK.

  13. In the Rule dialog box, click Add action.

  14. Under Action, click Switch views.

  15. Under View, click the name of the view that you want to display when the workflow status matches the status for this condition, and then click OK.

    For example, if you typed 2 in step 11, click the name of the view that you want to display when the workflow status is equal to In Progress.

  16. In the Rule dialog box, click OK.

  17. Repeat steps 4 through 16 to create additional rules to switch appropriate views at each stage in the workflow.

Top of Page

Step 4: Publish a form template as a site content type

When you publish a form template, you can either publish it to a document library or publish it as a site content type that can be used in multiple document libraries across a site collection. Because you already created a document library and assigned a workflow to it, you must publish the form template as a content type. Later, you can associate the form template's site content type to the library that you created.

In addition to publishing a form template as a site content type, you can also publish a form template to a shared network location or create a new document library, when you publish a form template to a SharePoint site. Find more information about publishing form templates in the See Also section.

  1. On the File menu, click Save.

  2. In the Save As dialog box, browse to the location where you want to save the form template, and then click Save.

  3. To open the Design Checker task pane, click Design Checker on the Tools menu.

  4. If there are errors listed the Design Checker task pane, fix those errors, and then click Refresh to determine if the errors still exist.

  5. On the File menu, click Publish.

  6. In the Publishing Wizard, click To a SharePoint server with or without InfoPath Forms Services, and then click Next.

  7. On the next page of the wizard, in the Enter the location of your SharePoint or InfoPath Forms Services site box, type the location of the SharePoint site where you want to publish your form template, and then click Next.

  8. To allow users to fill out this form by using a Web browser, on the next page of the wizard, select the Enable this form to be filled out by using a browser check box.

  9. Click Site Content Type (advanced), and then click Next.

  10. On the next page of the wizard, click Create a new content type.

  11. In the Base the content type on list, click Form, and then click Next.

  12. On the next page of the wizard, type a name and description for the new content type, and then click Next.

  13. On the next page of the wizard, in the Specify a location and file name for the form template box, type the location of the SharePoint site, and then click Browse.

  14. In the Browse dialog box, browse to the location on the server where you want to publish the form template as a site content type, and then in the File name box, type the name of the form template, and click Save.

  15. Click Next.

  16. Choose the fields in the form template that you want to appear as columns in the default view of the document library.

    How?

    1. Click Add.

    2. Select the field that you want to add as a column in the document library, and then do one of the following:

      • Type a name for the column in the Column name box.

      • Select the site column in the Site column group list, select a name in the Column name list, and then click OK.

        If you selected a repeating field to display data in the document library, you can define how you want to display the field in the document library by clicking a value in the Function list. You can choose whether to display the first value in the field, the last value in the field, or a count of all of the occurrences of the field, or whether to merge all of the values together.

    3. Click OK.

  17. Click Next.

  18. On the next page of the wizard, verify that the information shown is correct, and then click Publish.

  19. Click Close, and then verify that your form template is a content type on the SharePoint site.

    How?

    1. Open the SharePoint site in a Web browser.

    2. On the Site Actions menu in the upper-right corner of the site, click Site Settings.

    3. In Site Settings, under Galleries, click Site content types.

      Your form template should be listed under InfoPath Content Types in the Site Content Type Gallery.

Top of Page

Step 5: Add a content type to a document library

Content types make it possible for organizations to organize, manage, and handle content more effectively across a site collection. By defining content types for specific kinds of documents, an organization can ensure that each of these groups of content is managed more effectively. You can set up a list or library to contain items of multiple item types or document types by adding content types to the list or library.

Note: To add content types to a list or library, you need at least the Design permission level for that list or library.

Before you begin, make sure that the library is set up to allow multiple content types.

Allow multiple content types

  1. On the Settings menu, click Document Library Settings.

  2. Under General Settings, click Advanced settings.

  3. In the Content Types section, select Yes to allow multiple content types, and then click OK.

  1. If the list or library is not already open, click its name on the Quick Launch.

    Note: If the name of your list or library does not appear, click View All Site Content, and then click the name of your list or library.

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

  3. Under Content Types, click Add from existing site content types.

  4. In the Select site content types from list in the Select Content Types section, select the group of site content types from which you want to select.

  5. In the Available Site Content Types list, click the content type that you want, and then click Add to move the selected content type to the Content types to add list.

  6. To add additional content types, repeat steps 4 and 5, and then click OK.

Now, when a user creates a new form in this library, the view of the form will display according to the status of the workflow.

Top of Page

Share Facebook Facebook Twitter Twitter Email Email

Was this information helpful?

Great! Any other feedback?

How can we improve it?

Thank you for your feedback!

×