7.2. Using Form Libraries to Gather DataSharePoint form libraries are special document libraries for collecting data gathered through Microsoft InfoPath. Though purchased separately, InfoPath is part of the Microsoft Office System. It provides a platform for creating and displaying data-entry forms that may incorporate :
InfoPath's form-creation tools are based on XML and its related standards. It is perhaps most useful for medium-to-large corporations that use XML schemas as part of their information architecture. If you're not familiar with XPath, XML, XSD, and XSLT, you may find designing InfoPath forms difficult. On the other hand, filling out an InfoPath form is very easy.
7.2.1. Understanding Form LibrariesA form library is basically a document library that uses an InfoPath form template ( template.xsn ) as a template rather than a Word, Excel, or PowerPoint file. To add a new item to the library, members choose Fill Out Form and SharePoint opens the template in InfoPath, as shown in Figure 7-17. animal 7-17. Creating a new item in a form librarySharePoint comes with several sample templates that you can try. To create a test form library using one of the sample templates:
| |||
Form template | Use to | ||
---|---|---|---|
Absence Request | Request time away from work and to calculate remaining absence balances . | ||
Applicant Rating | Rate job applicants, comment on applicants ' strengths and weaknesses, and to provide a hiring recommendation. | ||
Asset Tracking | Keep a record of your company's equipment and property. You can track information such as primary user , location, and purchase date for each asset. The form can also be sorted, allowing you to quickly find the information you're looking for. | ||
Change Order | Explain and specify changes to existing orders or projects, as well as track total cost and time adjustments. | ||
Expense Report (Domestic) | Create and submit an itemized list of expenses. | ||
Expense Report (International) | Same as above, international travel. | ||
Invoice (Multiple Tax Rates) | Document sales and transactions, and to bill customers for services rendered or equipment delivered. | ||
Invoice (Single Tax Rate) | Same as above, one tax rate. | ||
Invoice Request | Request the generation of an invoice for services rendered or equipment delivered. | ||
Issue Tracking (Detailed) | Track an important issue, as well as provide details such as the due date, status, and owner for all action items that impact that issue. | ||
Issue Tracking (Simple) | Provide and track the details of an important issue, including the progress, contributors, and date closed. | ||
Meeting Agenda | Detail the agenda items, time allotments, guest speakers , attendees, and required materials for a meeting. This form can also be used to record meeting minutes, decisions, and action items. | ||
Project Plan | Provide the details for a project, such as schedule, work items, materials, and budget. | ||
Purchase Order | List the total items, total amount due, and required delivery dates for an order, and to authorize the delivery of the specified items. | ||
Purchase Request | Create a request for items you want to purchase. | ||
Sales Report | Record and track monthly sales of various items in different categories. | ||
Status Report | Provide an update on the status of various projects. These reports can then be combined into a single report. | ||
Service Request | Make requests for services or repairs . | ||
Time Card (Detailed) | Track time worked, including times in/out per day, absences, and other payroll information. | ||
Time Card (Simple) | Report the total hours worked during a specified time period. | ||
Travel Itinerary | Create a schedule of events while traveling, which can include transportation arrangements, appointments, and various contacts. | ||
Travel Request | Request the approval of a business trip and to provide details such as travel dates, destinations, itinerary information, and preferences so that accommodations can be made. | ||
Vendor Information | Specify the products and services provided by a particular vendor, and to allow multiple individuals to rate the vendor according to cost, quality, and delivery. |
When you save an InfoPath form to a form library, SharePoint saves the form data as an XML file in the library. SharePoint also maps elements from that XML file to columns in the SharePoint list using the Properties.xfp file found in the library's Forms folder. This process is similar to the way SharePoint promotes custom properties in Word and Excel document libraries. The advantage of this mapping is that you can use SharePoint to easily create different summary views of InfoPath data. These mapped fields are also included in searches of the site.
InfoPath is both a form designer and a form viewer. To design a data-entry form in InfoPath, start InfoPath, select one of the sample forms, and choose Design this form. InfoPath opens the form in design mode, as shown in Figure 7-18. You can modify the form by selecting any of the options in the task pane.
To preview the results of changes choose File Preview Form Default. InfoPath displays the form in Preview mode, as shown in Figure 7-19.
|
Once you are satisfied with a form, you have a choice: you can save the form for local use or testing, or you can publish the form to create a new form library in SharePoint. To publish a completed form:
Choose File Publish. InfoPath starts the Publish wizard to walk you through the process .
If you chose to publish to a form libary, the Wizard asks if you want to create a new form library or update the form in an existing library. Select Create new form library and choose Next .
Enter the SharePoint site in which to create the form library and choose Next. InfoPath logs on to the site and you may be prompted for your user name and password .
Enter a name and description for the form library and choose Next. The Wizard displays the mapping step (Figure 7-21). This step lets you map elements from the form's XML schema to columns in the form library. This mapping is maintained in the Properties.xfp file in the list's Forms folder.
Choose Add to create, Remove to delete, or Modify to change a mapping. Choose Finish to create the form library. InfoPath displays a success dialog box.
Once you've published the form, members can open it for data entry by choosing Fill Out This Form from the form library's toolbar. When members save the form InfoPath creates a new item in the form library as shown previously in Figure 7-17.
Form libraries are usually set up to collect data this way:
Choose Fill Out This Form from the library toolbar.
Complete, save, and close the form to create a new item in the library.
Open the item from the library to view/edit/modify the form as needed.
InfoPath also provides a Submit action for use in place of Save. Submit sends the form's data in XML form to a database or to an email recipient. Since SharePoint is really a database frontend, it's a bit redundant to submit to database from a form library.
However, submit via email does make sense. Consider this scenario: a support person completes a visit to a customer, fills out a service request, and emails it to the service manager. The manager views the request in Outlook; then saves it to a form library on SharePoint. Figure 7-22 illustrates this scenario.
In this scenario, the InfoPath form template (. xsn ) is installed on the service person's laptop or tablet as well as in the form library. That makes it possible to complete the form offline. The sample Service Request form doesn't come with submit enabled.
To add this feature to the form template:
Start InfoPath, select the Service Request sample form and choose Design this Form. InfoPath opens the form in design mode.
Choose Tools Submitting Forms. InfoPath displays the Submitting Forms dialog.
Enter the email address, subject, and message body you want to include when sending the form, choose Next, and then choose Finish to complete the task.
Choose Submit Options, select Close the form, and click OK twice to close the dialogs.
Once you've enabled submit, you can save and publish the template to a form library as described in the earlier section "Creating a Form Library." You'll also want to copy the template to the service person's laptop.
Enabling submit adds a Submit item to the File menu in InfoPath. Once the form is complete, the service person chooses File Submit to send the form. You can also add a command button to submit the form. To do that:
Open the template in design mode.
Choose Insert More controls. InfoPath displays the controls task pane.
Double-click the button. InfoPath displays the button's properties.
Select Action Submit. InfoPath displays the submit properties.
Add a checkbox to enable/disable other controls.
Set conditional formatting on those controls based on the checkbox setting.
Write code that sets the checkbox value.
Test the form.
Hide the checkbox once the form is working correctly.
The following sections demonstrate those tasks , using the Service Request example.
To add a new checkbox control on the form:
Open the template in design mode.
Choose Tools Submit Options, clear the Enable the Submit menu item on the File menu, and choose OK. You cant enable/disable menu items from a form so you must remove the menu item if you want to control access to Submit.
Display the Data Source task pane and choose Add. InfoPath displays the Add Field or Group dialog.
Add a Boolean field named DisableSubmit, as shown in Figure 7-24. Choose OK; InfoPath adds an element to the form's XML schema.
Drag my:DisableSubmit from the task pane onto the form. InfoPath creates a checkbox control on the form.
To enable/disable the Submit button based on the checkbox setting:
Double-click the Submit button and choose Display Conditional Formatting Add. InfoPath displays the Conditional Format dialog.
To write code to control the checkbox value:
Choose Tools Programming On Load Event. InfoPath displays the script editor.
|
To test the form:
Choose File Preview Form Default to check your code. Compiler errors will display an error message and prevent the preview. Runtime errors will display a script debug error but allow the preview.
Close the preview and choose File Save to save the form to the SharePoint library you created previously in "Creating a Form Library."