SharePoint and InfoPath: A Powerful Duo - 28 Mar 2007

Easily publish XML-based forms to your SharePoint site

Microsoft Windows SharePoint Services 2.0 is well known for its document-sharing and collaboration capabilities. IT professionals have been using it for several years now as both a document repository and an area for team workspaces. With document libraries, task lists, discussion threads, and other features, SharePoint Services 2.0 offers users the ability to access and distribute content quickly.

One lesser-known feature of SharePoint Services 2.0 is the form library, which allows for the management of XMLbased form files. For the IT professional, the advantage these form files have over other types of files (for example, Microsoft Office Word 2003 documents) is obvious: Form files are structured and consistent. Because the XML standard focuses mainly on content, the form library files aren't riddled with varying degrees of formatting and thus are easier to process than Word documents. Of course, creating these form files requires an XML editor such as Microsoft Office InfoPath 2003 Service Pack 2 (SP2). Fortunately, there's strong integration between SharePoint Services 2.0 and InfoPath 2003 SP2.

After I give you a brief overview of InfoPath and its form designer, I'll walk you through the various options and processes involved in deploying an InfoPath form template to a SharePoint site. I'll also review some of the form library modifications that you'll need to make after you publish the form template.

About InfoPath
In a nutshell, InfoPath is an application that lets you design and fill out electronic forms. The InfoPath form designer uses an XML schema, controls bound to schema elements, data connections, data validation, and conditional formatting within a template. End users can enter data in the fields as needed. Form data is stored as XML, which is then either submitted to a specified location such as a SharePoint form library or saved to the user's local drive.

When you create an InfoPath form, you can build it from scratch or use one of the built-in sample templates that help you implement scenarios such as status reporting, issue tracking, and purchasing. For this article, I'll be using the sample Status Report template to design the form, but you can use the techniques here to design forms based on any of the other sample templates.

When you look at the sample Status Report form, which Figure 1 shows, you can see some of the controls that are available, including

  • a date picker control and text box controls at the top of the form
  • rich text box controls in the Summary and Notes sections
  • bulleted list controls in the Last Period, This Period, and Issues sections.

Each control is bound to an element in the form's data source. This data source is mapped to an XML schema, which identifies the structure of the form file and the data types for the individual elements. When users enter data in a form, that data conforms to the rules specified in the associated XML schema.

Data Validation
You can add rules to controls to validate data that users enter. For example, if you want to flag a time report entry that exceeds 40 hours for time spent, you can add a validation rule for the spent element. At runtime, if the user enters data that violates the rule, a red border would appear around the text box control with a screen tip or message indicating the nature of the validation problem. To create this validation rule, perform these steps:

  1. In the Time Report repeating table, double-click the text box bound to the spent element.
  2. In the Text Box Properties dialog box, click Data Validation.
  3. In the Data Validation text box, click Add.
  4. In the middle box at the top of the dialog box, select is greater than from the drop-down list, as Figure 2 shows.
  5. In the third box, select Type a number from the drop-down list and enter 40 in the box.
  6. In the ScreenTip box, type a message or screen tip explaining the problem.
  7. Click OK until all dialog boxes have been closed.

Conditional Formatting
Another option available when you design a form is conditional formatting, which you can use to enable or disable controls in the form view. For example, if you want to add logic that disables the Department text box when data has already been provided in the E-mail Address text box, you can add a conditional formatting rule to the Department text box control. The following example shows how to create this conditional formatting rule:

  1. Double-click the text box bound to the department element.
  2. In the Text Box Properties dialog box, click the Display tab.
  3. Click Conditional Formatting.
  4. In the Conditional Formatting dialog box, click Add.
  5. In the first box at the top of the Conditional Format screen, select emailAddressPrimary from the drop-down list, as Figure 3 shows.
  6. In the second field, change the value to is not blank.
  7. Select the Read-only check box
  8. Click OK until all dialog boxes have been closed.

SharePoint Data Connection
When designing form templates that are to be used with SharePoint Services, you can create data connections that allow users to submit form files to a SharePoint form library. InfoPath 2003 SP2 has a built-in SharePoint submit adapter that enables form designers to specify a SharePoint form library URL. InfoPath also lets you create the library that will host the form template. I'll walk you through the form library-creation process, but first let's look at the process of creating a SharePoint data connection for submitting forms.

At the time you're creating the SharePoint data connection, it's likely that a SharePoint Services site already exists. However, it's also likely that the library hosting the form template doesn't. When using the InfoPath Data Connection Wizard, you'll need to record the form library URL that you specify, as it will be used later when publishing the form template. The following steps show how to create a SharePoint data connection in InfoPath 2003 SP2 for our Status Report sample:

  1. Click Tools, Data Connections.
  2. In the Data Connections dialog box, click Add, which opens the Data Connection Wizard.
  3. On the wizard's first screen, click Submit data and click Next.
  4. Select To a SharePoint form library and click Next.
  5. In the SharePoint form library box, type the URL for the form library that will host the form template. In our example, we'll be creating a Status Report form library on our SharePoint Services Reports site, so we'll use this URL: http://server2003ee/sites/reports/status.

In addition to the form library URL, you must specify a naming convention for submitted form files. It usually makes sense to use form field values in file names to help ensure uniqueness in your naming convention. The concat function lets you combine two or more field values for specifying file-names. Continuing in the Data Connection Wizard, you'll perform the following steps to use the Status Report's Name and Date fields for a filenaming convention:

  1. Click the function (fx) button, located to the right of the File name box.
  2. In the Insert Formula dialog box, click Insert Function.
  3. In the Insert Function dialog box, double-click the concat function.
  4. In the Insert Formula dialog box, in the Formula box, double-click the first prompt within the concat function (e.g., double click to insert field), as Figure 4 shows.
  5. In the Select a Field or Group dialog box, expand the Employee group, then the Name group, and double-click singleName.
  6. In the Insert Formula dialog box, in the Formula box, double-click the next prompt within the concat function.
  7. In the Select a Field or Group dialog box, double-click date.
  8. In the Insert Formula dialog box, in the Formula box, delete the comma after date and delete the third prompt within the concat function, which Figure 5 shows
  9. Click OK.
  10. In the Data Connection Wizard, select the Allow overwrite if file exists check box.
  11. Click Next, then click Finish.
  12. In the Data Connections dialog box, click Close.

User Submit options
By default, submit options aren't enabled in your form template, even when you've defined a submit data connection. However, it's relatively simple to enable submit commands on the InfoPath toolbar. You can also easily define InfoPath's behavior when submitting forms (e.g., closing the form template after a submit operation is complete). To enable submit options for our Status Report example, perform these steps:

  1. Click Tools, Submitting Forms.
  2. In the Submitting Forms dialog box, click Enable Submit commands and buttons, as Figure 6 shows.
  3. In the Submit to drop-down list, select SharePoint form library.
  4. Click Submit Options.
  5. In the Submit Options dialog box, click Close the form and click OK.
  6. In the Submitting Forms dialog box, click OK.

Promoting Column Names
Before you publish the template, you can define column names for the SharePoint form library to which the template will be published. These column names are based on elements in the form template, and you can change the names as needed. This promotion offers SharePoint users read access to some of the data in the corresponding form files, without requiring InfoPath 2003 SP2 to be installed.

The Status Report sample defines five column names for its form data. In the following example, we remove two of those columns and add one for the submitter's email address:

  1. Click Tools, Form Options.
  2. In the Form Options dialog box, click the Form Library Columns tab.
  3. Click Manager Name and click Remove.
  4. Click Department and click Remove.
  5. Click Add.
  6. In the Select a Field or Group dialog box, expand the employee group and click emailAddressPrimary.
  7. In the Column name box, type E-mail and click OK.
  8. In the Form Options dialog box, click OK. Figure 7 shows an example of the promoted columns

Deploying the Form Template
After you identify the SharePoint column names, you can now use the InfoPath Publishing Wizard to deploy the form template. The following steps show how to create a new Status Report form library on your SharePoint Services Reports site:

  1. Click File, Publish, to open the InfoPath Publishing Wizard.
  2. In the first screen, click Next.
  3. Select To a SharePoint form library and click Next.
  4. Click Create a new form library (recommended) and click Next.
  5. In the Enter the location of your SharePoint site field, type the URL you entered when creating the SharePoint data connection (e.g., http://server2003ee/ sites/reports) and click Next.
  6. Type status in the Name box and type a description in the Description box, as Figure 8 shows.
  7. Click Next. Click Finish, then click Close.

Modifying the Form Library
The last order of business is to tidy up the newly created form library. Usually, this involves simply modifying the general settings for that library. By default, the display name for the library is the same as the name you specified in the Publishing Wizard. The following example shows how to change the display name of status to Status Report:

  1. In Microsoft Internet Explorer (IE), navigate to http://server2003ee/sites/reports/status.
  2. In the left navigation bar, click Modify settings and columns.
  3. On the Customize status screen, in the General Settings section, click Change general settings.
  4. On the Form Library Settings: status screen, in the Name and Description section, type Status Report in the Name box and click OK.

In addition to changing the form library name, you might need to adjust settings for displaying columns. By default, all the fields that you promoted as SharePoint columns during the publishing process will appear in the All Forms view of the form library, but there are additional built-in SharePoint columns that you might prefer to suppress in this view. Continuing on the Customize Status Report page, perform these steps to customize column settings in the All Forms view:

  1. On the Customize Status Report page, click All Forms.
  2. On the Status Report: Edit View page, in the Columns section, clear the Display check boxes for the Type (icon linked to document), Modified, Modified By, and Checked Out To (link to username to user details page) columns.
  3. For the E-mail column, change the Position from Left value to 7.
  4. Click OK.

Better Together
Strong integration exists between SharePoint Services 2.0 and InfoPath 2003 SP2, which gives IT professionals another option for easily collecting and sharing information in a collaborative environment. InfoPath stores data as XML-based form files. These files have a consistent structure, and thereby are more predictable than other file types if programmatic requirements arise. However, InfoPath 2003 SP2 provides no browser-form capabilities. Users must have the InfoPath client installed on their machines to access the rich controls, advanced data validation, and conditional formatting of form files. Therefore, you might consider upgrading to Office InfoPath 2007, which does provide browser-form capabilities for InfoPath form files.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.