Chapter 9. InfoPath Integration

This chapter switches gears a bit to talk about an application called Microsoft Office InfoPath 2010. InfoPath, which is a form generation tool that has been part of the Office suite since 2003, has become an integral part of the SharePoint products and technologies. In this chapter, you discover how you can use InfoPath easily and efficiently to manage SharePoint list and library forms. You also learn about the InfoPath Form web part that ships with SharePoint Server 2010 Enterprise and lets you expose InfoPath forms alongside your other SharePoint components.

THE PATH TO GATHERING INFO

When InfoPath 2003 was released as part of Office 2003, it was ahead of its time, because it was the only product within the Office suite that utilized the power of XML in its inner workings. An InfoPath form is based completely on an XML schema and offers structural editing of the XML data. It is the most appropriate platform for gathering data in the Microsoft Office suite of applications, and the user interface provided is very much like Microsoft Word, so the ramp-up time for a new form designer is minimized. You can build dynamic data-driven forms without needing a programming background.

The latest revision of the product is Microsoft InfoPath 2010. The fluent interface (ribbon) has been introduced in the product, which now provides it a consistent look and feel with the other Office products. Two InfoPath applications are available — Microsoft InfoPath Designer 2010 and Microsoft InfoPath Filler 2010. Designer is used by the form designers to design the form, whereas the Filler is used by the end users to fill out a form and save it. In addition to filling out the form in the Filler, you can also allow end users to fill out forms using the browser, provided that you have the enterprise license of SharePoint Server 2010, which ships with the needed component, Forms Server, to serve up the forms. InfoPath 2010 web browser forms are compliant with Web Content Accessibility Guidelines 2.0 (WCAG 2.0) and are fully XHTML 1.0 compliant. To find more information on the enterprise licensing of SharePoint Server go to http://sharepoint2010.microsoft.com.

A form designer uses InfoPath to create form templates for end users to fill out. After opening the InfoPath Designer application, the first decision that a form designer must make is to choose the type of form template. The Backstage screen of Designer helps with this process. As is apparent in Figure 9-1, you can choose from many form templates.

Figure 9-1

Figure 9.1. Figure 9-1

You can utilize InfoPath Designer to edit SharePoint list or library forms. This chapter provides an example of this functionality later. You can utilize InfoPath completely independent of SharePoint by creating template forms that can be used on their own. You can place form templates on a network share or on an intranet from where users can obtain and fill out the forms. In addition, you can send forms directly to people's inboxes, where they can fill out the form within the Microsoft Outlook 2010 environment and submit it back to the person who sent them the form.

The Designer environment provides a quick and easy interface to get started building your forms. Assuming you start by using the Blank Form template, which starts you out by providing just an empty table, you can quickly decide on a page layout for your form by selecting the Page Design tab and picking a Page Layout template. Then pick a theme for your form by selecting from the provided theme choices. Figure 9-2 shows the page layout templates and a brief view of the available themes.

Figure 9-2

Figure 9.2. Figure 9-2

Form templates generally consist of labels and controls through which you want to accept user input. These elements are best arranged in a table. By clicking on the Insert tab, you see a number of choices for table styles, as shown in Figure 9-3. Pick the style(s) that best suits your need.

Figure 9-3

Figure 9.3. Figure 9-3

The next step in creating the form is to populate it with descriptive text and the controls needed for the form. You insert the text and labels simply by typing them directly onto the appropriate places in the form. The controls for the form are available through the Home tab. This is where the true design power of InfoPath forms are realized, because you can use a variety of controls as the designer. As Figure 9-4 shows, controls such as text box, drop-down list, date picker, button, repeating table, and more are all available in the Home tab, ready to be placed on the form. Just place your cursor at the place you want the control to appear and click on the control to insert it in the form template.

Figure 9-4

Figure 9.4. Figure 9-4

The form template is aware of the controls placed on it and their associated properties. The form designer can access controls by their name and use them as needed, so a best practice to follow is immediately to name all the controls on the form. You access a control's name and other properties by first clicking on a control and then using the Control Tools tab that appears in the ribbon. The Fields task pane on the right side of the screen reflects that change.

After a form template design meets a designer's required specifications for what the form is intended to accomplish, the next step is to manage the dynamic aspects of the form by using proper validation and formatting rules. This aspect of the form is discussed in the next section.

Using Rules for Conditional Formatting and Data Validation

The InfoPath Designer environment allows you the use of a rules engine with which you can decide how your form and the controls on the form should behave in response to the data that the end user provides. Three types of rules can be created using the rules management interface:

  • Validation — Validate the entered data in controls.

  • Formatting — Change formatting of a control based upon defined condition criteria.

  • Action — Perform an action (such as setting a field's value or submitting data) based upon defined condition criteria.

You can quickly start incorporating rules in your form by using quick rules. These are a set of pre-built rules that help validate your data and make forms more dynamic. Simply click on the control that you want to set a rule upon, click the Add Rule button in the ribbon, and then select the condition and subsequent action from the list of options that appear. Figure 9-5 shows a snapshot of these rules in Figure 9-5.

Think of quick rules as a wizard to get you started. You can start instead from scratch by clicking on the Manage Rules button on the ribbon, which displays the Rules task pane on the right, to manage rules. The same task pane also appears after you have picked a quick rule, and lets you manage the properties of that rule further (such as changing its name) as needed. You can configure as many rules as needed for the control. The control's rules appear on this task pane when you place the control in context by clicking on it. You created a new rule by clicking on the New button in the Rules task pane and selecting the appropriate type of rule. A rule is set up much like a mini-workflow in which you define a condition and then a subsequent action for which the condition becomes true. For example, designate a field as required to contain content, so that, if the field is blank and the user tries to submit the form, it shows a validation error. An example of a formatting rule would be to check a field's value with the value of another field to determine whether they are the same, and to change the background color of one or both fields to red to signify when they are not. Figure 9-6 shows a couple of configured rules for a control.

Figure 9-5

Figure 9.5. Figure 9-5

In a typical form created for business use, you might need to create numerous rules for the controls. A very useful functionality available is the ability to copy and paste rules from one control to another. To copy single or multiple rules, simply select them and click on the copy icon that appears within the Rules task pane. Then select the control to which you want to paste the rule(s), and click on the paste icon in the Rules task pane. All of your rules along with their defined logic are copied to the new control saving you lots of time and effort.

The end goal is for you to publish the form template to a location where users can access it and fill it out with their data. Publishing is covered later in this chapter. Before publishing your form, using the Preview button on the Home tab of the ribbon to preview your form and run through its logic is always a good idea. Figure 9-7 shows how the preview screen looks.

Figure 9-6

Figure 9.6. Figure 9-6

Figure 9-7

Figure 9.7. Figure 9-7

Fetching Data from Multiple Repositories

InfoPath can make data connections to various data repositories. Depending on what you want the form to do, you can set up data connections for either retrieving data or submitting it to a data source. This section focuses on the receiving part of the equation. The Data tab (see Figure 9-8) within the InfoPath client displays the various repositories of external data you can use.

Figure 9-8

Figure 9.8. Figure 9-8

Following is a list of external data connections you can create:

  • SOAP web service (Simple Object Access Protocol web service)

  • REST web service (Representational State Transfer web service)

  • SharePoint library or list

  • Database (Microsoft SQL Server only)

  • XML Document (any URL you can connect to that would return an XML document — for instance, an RSS feed)

You can create each of these connections very simply by following the wizard that appears after you select your data source type. Just because an option to connect to non-SQL databases does not exist in the user interface does not mean that it is not possible. You can use web services to connect to any non-SQL databases (provided that those databases expose web services to consume).

A query data connection gets data from the external data source, which you can then bind to any fields within the form. You see an example of making a connection to a SharePoint list and binding that information to a combo box later in this chapter.

Publishing Forms to a Variety of Locations

An InfoPath form template is saved as an .xsn file. When you publish the form, this file becomes accessible to the end users and works very much like a Microsoft Word document template (.dotx file). The user opens the file and fills out the required information on the form. When the user decides to save or submit the form, it gets saved as an .xml file containing all the user-provided data and a pointer to the original .xsn file used to create this instance.

Publishing and sharing the InfoPath form using SharePoint is recommended. SharePoint framework provides a multitude of built-in options to support the form processes. If your SharePoint instance is running with enterprise client access licenses then the only thing that the users need is the browser to fill out the forms. If SharePoint Server standard licensing or just SharePoint Foundation is deployed, then the end user needs the InfoPath Filler application to fill out the forms. When the form template is published to the form library in SharePoint, the users can take advantage of all the base features available within every library, such as versioning, check-in/check-out, and the ability to attach workflows to the library. The form library provides a superset of features available in a document library. In addition to all the base features of a typical library, a form library is recognized inherently by InfoPath, which can publish forms directly to it. You see an example demonstrating this process later in this chapter. An added benefit of hosting the forms in a form library is that it contains a special built-in view called Merge View that lets you merge the information of multiple instances of the filled-out forms that are hosted in the library.

The publishing options are available through the Publish option on the File tab in the ribbon as shown in Figure 9-9.

Figure 9-9

Figure 9.9. Figure 9-9

In addition to publishing to the SharePoint Server, you can also publish the InfoPath form template directly via e-mail to user's inboxes or place it on a network location that's accessible to the intended audience. Both of these options require that users filling out the form have the InfoPath Filler application available to them on their computer. The process to publish the form to a network share is the simplest available within the Designer environment. It entails just pointing to the location where the .xsn file needs to be saved. After the file is published to that location, you can notify your users (via e-mail or otherwise) to fill out the forms using this template. Figure 9-10 shows the wizard screen that you use to define the location and name of the form.

Figure 9-10

Figure 9.10. Figure 9-10

In a scenario where, for example, you want to collect some information from your users quickly, you can send them an e-mail with the form prominently displayed in the body of the e-mail. As long as the user has InfoPath on his computer, he will see the form ready to be filled out. The E-mail button in the Publish screen starts up the e-mail client and guides the form designer through the process of sending the form. When the end user receives the e-mail, all he will then need to do is to fill out the form directly in the e-mail client application and submit it. The form designer must configure the submission process of InfoPath beforehand for this process to work. It can be configured automatically to submit the form to a variety of places, including sending the form back through e-mail, sending it to a library or to a predefined connection in SharePoint, and submitting to a web service. The submission options are available through the Info selection under the File tab as Figure 9-11 shows.

The information in the preceding sections provide enough guidance to get you started with Microsoft InfoPath 2010. However, by no measure is it an exhaustive list of features available within InfoPath 2010. Learning this product further by picking up a good book that's dedicated to this subject is definitely advisable. Because no books are published on InfoPath 2010 just yet, I advise going through a good InfoPath 2007 book, such as Designing Forms for Microsoft Office InfoPath and Forms Services by Scott Roberts and Hagen Green (Addison-Wesley, 2007). This book provides you a good basis for the internals of this product and opens your mind to the possibilities of what is achievable with this platform.

Figure 9-11

Figure 9.11. Figure 9-11

CUSTOMIZING SHAREPOINT LIST FORMS

When you use a list template in SharePoint to create a new list, it automatically deploys a number of forms for viewing, editing, and creating items in that list. You are not limited to these forms and are allowed to create new forms for users to interact with list data. Chapter 8 discusses and demonstrates the way to create new list forms using SharePoint Designer 2010. You can use those methods with any version of SharePoint. However, if you have the SharePoint Server enterprise license, you have an additional option to customize your list forms using InfoPath 2010.

The earlier sections in this chapter explained the power of InfoPath and declared it as a preferred tool for form generation and manipulation in SharePoint. This section demonstrates how you can use this tool to create robust SharePoint list forms.

Building List Forms Using InfoPath

Building list forms is a new functionality in InfoPath 2010. Earlier versions of InfoPath did not let you create SharePoint list forms. Because InfoPath is the preferred Microsoft tool for form generation, letting this powerful tool generate forms for SharePoint lists and libraries as well just makes sense. In the previous versions of InfoPath, you could use it to create SharePoint library forms (discussed later in this chapter). Now the additional functionality for creating SharePoint list forms has been integrated into the platform. The list form creation process can be instantiated from within InfoPath by choosing the SharePoint List form template, or you can start directly from a SharePoint list as demonstrated in the next exercise.

Displaying Forms Using InfoPath Form Web Part

The InfoPath form web part has been introduced as a new web part in SharePoint Server 2010. You need the SharePoint Server Enterprise license to have access to this web part in the web part gallery. InfoPath forms have been capable of being displayed in the browser for many years now using InfoPath Forms Services. Nevertheless, many users have wished that they could encapsulate their forms within a web part that they can then deploy to any SharePoint page. Well, this capability is now possible with the InfoPath form web part!

Back in SharePoint Server 2007, users who wanted to host their InfoPath forms on Web pages had to utilize the XmlFormView control and write code in Visual Studio. You can now accomplish the same goal without writing a single line of code using the InfoPath form web part. The InfoPath form web part works by hosting any already-published InfoPath form on the site. The two types of forms that it can consume are the following:

  • An InfoPath browser form that is published to a form library (covered later in the chapter).

  • A form associated with a SharePoint list that has been customized by using InfoPath Designer 2010.

You can configure all common web part properties, such as the title, appearance, and behavior of the web part, directly from the web part properties task pane in the browser. You can also connect the InfoPath form web part to other web parts on the page to send or receive data.

The following exercise shows an example of how to use this web part to show a SharePoint list form.

CUSTOMIZING SHAREPOINT LIBRARY FORMS

All SharePoint libraries require at least one document template to be associated with them. For example, when you create a document library, you have the option of choosing Word, PowerPoint, Excel, or other applications to be the default document template for the library. When a user clicks on the New Document button in the library, he is then presented with the appropriate document template.

InfoPath can also serve as the default document template for a library. The special type of a library that is created to host InfoPath form templates is a form library. Figure 9-18 shows the form library in the Create dialog.

Figure 9-18

Figure 9.18. Figure 9-18

Form libraries have been around since SharePoint 2003 and have served as a place to hold and manage forms. The InfoPath environment inherently understands form libraries in SharePoint. The form publishing process in InfoPath can either create a new form library or publish a form to an existing form library. The following sections detail the process of creating an InfoPath form and publishing it to a new form library.

Creating the InfoPath Form Template

The first decision you have to make when creating a new InfoPath form template for a library is to choose the appropriate template with which to start. You can start from scratch, if you like, using the Blank Form template, and then choose the design layout for the form, add controls, create rules, and apply formatting. Or you can start with the built-in SharePoint Form Library template that starts you off with a built-in layout that you can then customize to your needs. The following exercise uses the Form Library template as the starting point.

Publishing to the Form Library

Publishing InfoPath forms to form libraries is the recommended way to share these forms with users. Because a form library is just an enhanced version of the document library, it takes advantage of all the library features, as well. For example, security at the library, folder, and item levels is available to be set as needed. Check-in/check-out and versioning functionality is available for all forms that would be hosted in the form library, and because all content in SharePoint is stored in the content databases, the forms would be securely stored there as well.

In addition to merely storing the forms in the form library, you can use them to participate in workflows. Form libraries, just like all other libraries in SharePoint, can have workflows associated with them. One of the ways workflows can be initiated is when a new form is created in the library. Workflows attached to the library can then take advantage of all column information in the library, including the columns that are displaying InfoPath form data. In effect, you can use the form data within your workflows, which makes for an extremely powerful solution. You can use SharePoint Designer 2010 to create workflows and attach them to a library. Chapters 11 and 12 cover these workflows.

In addition to the functionality of "saving" the form to your library, you also have the option to set up the "submit" functionality on your form. You can utilize the submit settings to submit the form to one or more locations, such as a web service and a form library. The submit function is the recommended option to have available for end users. Setting up the submit function requires quite a few more steps and is out of the scope of this chapter; however, you can see the submit functionality in action if you want in a demo presented at www.sharepoint-videos.com.

SUMMARY

Microsoft InfoPath 2010 is Microsoft's preferred tool for form design and generation. With the release of SharePoint 2010, InfoPath has now become a critical component of the SharePoint products and technologies family. It is a robust platform that can be used to create dynamic forms for SharePoint lists and libraries.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.45.5