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.
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.
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:
- In the Time Report repeating table, double-click the text box bound to the spent element.
- In the Text Box Properties dialog box, click Data Validation.
- In the Data Validation text box, click Add.
- In the middle box at the top of the dialog box, select is greater than from the drop-down list, as Figure 2 shows.
- In the third box, select Type a number from the drop-down list and enter 40 in the box.
- In the ScreenTip box, type a message or screen tip explaining the problem.
- Click OK until all dialog boxes have been closed.
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:
- Double-click the text box bound to the department element.
- In the Text Box Properties dialog box, click the Display tab.
- Click Conditional Formatting.
- In the Conditional Formatting dialog box, click Add.
- In the first box at the top of the Conditional Format screen, select emailAddressPrimary from the drop-down list, as Figure 3 shows.
- In the second field, change the value to is not blank.
- Select the Read-only check box
- 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:
- Click Tools, Data Connections.
- In the Data Connections dialog box, click Add, which opens the Data Connection Wizard.
- On the wizard's first screen, click Submit data and click Next.
- Select To a SharePoint form library and click Next.
- 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:
- Click the function (fx) button, located to the right of the File name box.
- In the Insert Formula dialog box, click Insert Function.
- In the Insert Function dialog box, double-click the concat function.
- 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.
- In the Select a Field or Group dialog box, expand the Employee group, then the Name group, and double-click singleName.
- In the Insert Formula dialog box, in the Formula box, double-click the next prompt within the concat function.
- In the Select a Field or Group dialog box, double-click date.
- 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
- Click OK.
- In the Data Connection Wizard, select the Allow overwrite if file exists check box.
- Click Next, then click Finish.
- 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:
- Click Tools, Submitting Forms.
- In the Submitting Forms dialog box, click Enable Submit commands and buttons, as Figure 6 shows.
- In the Submit to drop-down list, select SharePoint form library.
- Click Submit Options.
- In the Submit Options dialog box, click Close the form and click OK.
- 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:
- Click Tools, Form Options.
- In the Form Options dialog box, click the Form Library Columns tab.
- Click Manager Name and click Remove.
- Click Department and click Remove.
- Click Add.
- In the Select a Field or Group dialog box, expand the employee group and click emailAddressPrimary.
- In the Column name box, type E-mail and click OK.
- 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:
- Click File, Publish, to open the InfoPath Publishing Wizard.
- In the first screen, click Next.
- Select To a SharePoint form library and click Next.
- Click Create a new form library (recommended) and click Next.
- 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.
- Type status in the Name box and type a description in the Description box, as Figure 8 shows.
- 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:
- In Microsoft Internet Explorer (IE), navigate to http://server2003ee/sites/reports/status.
- In the left navigation bar, click Modify settings and columns.
- On the Customize status screen, in the General Settings section, click Change general settings.
- 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:
- On the Customize Status Report page, click All Forms.
- 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.
- For the E-mail column, change the Position from Left value to 7.
- Click OK.
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.