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:
- 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.
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:
- 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.