C H A P T E R  11

Using InfoPath Forms

InfoPath forms allow designers to create rich, custom forms that can create and consume data from a variety of sources including SharePoint. In this chapter, you will explore the features of InfoPath forms that make them well-suited to inclusion in a SharePoint-based solution. You will examine the concepts and security considerations to be addressed when working with InfoPath forms in SharePoint. You will then learn the process for building and publishing different types of forms for use within SharePoint.

You will learn about the following topics in this chapter:

  • The basics of creating web-enabled forms by using InfoPath 2010
  • The limitations placed on web-based forms in terms of security and functionality
  • How to control the deployment of form templates in a SharePoint environment
  • How to customize SharePoint list forms by using InfoPath form templates
  • How to integrate custom document information panels with Microsoft Office applications such as Word or Excel

Introduction to InfoPath

Let's start off our discussion of InfoPath by pointing out that this book is about SharePoint Designer, not InfoPath. Why then is this chapter called “Using InfoPath Forms”? That's a good point…on to Chapter 12!

Just kidding. The reason for discussing InfoPath here is that data entry forms occur naturally in many situations when designing SharePoint sites. InfoPath and SharePoint are designed to work well together, and some interesting features can best be leveraged by using both technologies together. This chapter will not attempt to teach you everything there is to know about designing InfoPath forms. There are many good books on that subject already. The purpose of this chapter is to introduce the concepts of InfoPath and to explore the situations for which a SharePoint site designer may find using InfoPath forms helpful.

The Form-Filling Environment

When Microsoft released InfoPath as part of MS Office 2003, it saw slow adoption because of the way users had to fill out forms. The MS InfoPath 2003 client application was used to both create form templates and fill out forms. In order to get InfoPath, most organizations had to sign up for volume licensing and more-expensive editions of MS Office. Although integration with SharePoint was considered a valuable feature, there was no way to create a web-based data entry form in InfoPath. Because most users did not have InfoPath on their desktops, deploying an InfoPath form in any but the most controlled internal-facing scenario was impractical.

Compare this situation with InfoPath's competitors such as Adobe's Acrobat forms. Acrobat forms can be designed using the full Acrobat client application, but they can be filled out using the Acrobat Reader application, which is available as a free download. The lack of an equivalent form-filling environment caused many organizations to reject InfoPath as a solution.

When InfoPath 2007 was released, it provided the capability to create web-based forms. These form definitions were designed to run within SharePoint's InfoPath Forms Services subsystem. Forms Services was included in the Enterprise license of MOSS 2007 or as a separate product called SharePoint Forms Services 2007. This strategy eliminated much of the restriction on InfoPath's adoption, but web-based forms have certain security limitations that prevent them from being used in all cases.

images Tip The fact that a form template is deployed to SharePoint does not require that it be web-based. A non-web-based form opened from SharePoint will open in InfoPath Designer or InfoPath Filler if available. Only if InfoPath is not available will this type of form fail to open.

With the release of InfoPath 2010, Microsoft has adopted a three-pronged strategy for filling out forms. InfoPath forms can now be used in three distinct environments:

  • InfoPath Designer 2010: This Windows-based client application is used to design or fill out InfoPath form templates. This is the authoring environment for forms.
  • InfoPath Filler 2010: This Windows-based client application is used to fill out forms based on form templates designed in the designer application. This application allows forms to use the same security model as forms running in InfoPath Designer.
  • InfoPath Forms Services 2010: This is a subsystem within SharePoint Server 2010 Enterprise Edition that hosts web-based InfoPath forms. This allows a user to complete and submit forms without installing any client application, but with more-restricted functionality.

images Note Unfortunately, the new InfoPath Filler application is not the revolution it seems to be. Microsoft did not see fit to release it as a free download like Acrobat's Adobe Reader application. In fact, under the covers, this application runs the same executable as the InfoPath Designer. It just runs in a different mode. As such, users still need to buy an upscale edition of MS Office in order to use it. The same barriers to adoption exist for InfoPath 2010 that were present in the 2007 version.

What's New in InfoPath 2010?

The 2010 release of InfoPath contains new features to make forms easier to design, more functional to use, and more versatile to host and deploy. These new features can be divided into three main categories, as follows:

  • Designing form templates
    • Page layouts: Allow the designer to apply a variety of standard layouts to a form view.
    • New controls: Include picture buttons, date/time pickers, person/group pickers, digital signatures and managed metadata pickers.
    • Improved rules engine: New types of rules allow the quick creation of complex behaviors without coding. Also includes an improved rule management interface.
    • Quick Publish button: This option allows the designer to republish a previously published form without going through the entire publishing wizard again.
  • SharePoint integration
    • SharePoint list forms: The new display and edit forms generated for a SharePoint list can be replaced with an InfoPath form template for added control and functionality.
    • SharePoint workspace integration: SharePoint lists and libraries taken offline using SharePoint Workspace (previously known as Groove) can still leverage InfoPath forms. Forms entered offline are synchronized with SharePoint when a new connection is made.
  • Web-based forms
    • More supported controls: Includes lists, list and combo boxes, picture buttons, hyperlinks, pickers, and sections.
    • InfoPath Form web part: This web part allows any InfoPath web-enabled form to be hosted on a web page in SharePoint, including connecting the form to other web parts via web part connections.
    • Browser standards compliance: The new version is compliant with XHTML 1.0 and Web Content Accessibility Guidelines 2.0 (WCAG 2.0) AA.

InfoPath Integration with SharePoint

InfoPath integrates with SharePoint in several ways, but the underlying technology supporting that integration is the InfoPath Forms Services subsystem. This component is part of the Enterprise edition of SharePoint Server 2010.

Forms Services is configured in SharePoint's Central Administration site. Unlike other SharePoint services, such as Excel Services or PerformancePoint Services, Forms Services is not a service application configured under Application Management. To configure Forms Services, select the General Application Settings link in the left-hand menu and look for the InfoPath Forms Services group.

To enable InfoPath Forms Services features within SharePoint site collections, you have to activate the SharePoint Server Enterprise Site Collection feature. This feature activates the web parts and menu actions necessary to host InfoPath forms within the site collection.

After you have configured and enabled Forms Services in the site collection, you can use the InfoPath form templates in various ways. InfoPath forms are XML-based. This means that all of the data entered is encoded into an XML document that is then submitted to a data store of some kind. The most basic use of InfoPath forms in SharePoint is to use a SharePoint document library as a repository for storing completed forms. SharePoint provides several features that are useful when working with forms, including versioning, access security, and workflow processing.

A form template can be integrated with a library in two ways. The simplest way to surface a form in a library is to publish the form template as a document template in the library. The problem with this method is that the form template is stored specifically for this library and isn't usable elsewhere in the site. A better approach is to associate a form template with its own content type. Adding the form's content type to a library allows forms to be filled out and stored in the library. The advantage is that the content type becomes a centralized location for managing the form template. You will explore creating a form content type in Exercise 11-1 later in this chapter.

The next most common use for InfoPath within SharePoint is for creating customized forms for workflows. SharePoint workflows allow users to perform controlled business processes managed by the Windows Workflow Foundation (WF) engine hosted within SharePoint. The WF engine can assign tasks, send e-mails, or perform a number of other activities in order to complete a business process. At each step in the process, user input may be required. The forms for entering this data are called task forms. InfoPath can be used to create highly customized templates for the forms. You will explore this type of form in Chapter 12 when you examine SharePoint's workflow features.

A new feature in InfoPath and SharePoint Server 2010 is the ability to create custom list forms in InfoPath. When a list or library is created in SharePoint, a set of default data entry forms is created. These forms create new items and edit or display existing items. A site designer can now customize these forms by using InfoPath form templates more easily than using the other methods available. You will customize list forms in Exercise 11-2 later in this chapter.

The final scenario where InfoPath forms are useful to site designers is when using SharePoint in conjunction with other MS Office client applications such as Word or Excel. Office applications allow the document author to set document properties such as the author, title, keywords, and so on. These properties can be viewed in the document information panel (DIP). In Word 2010, this panel can be displayed by selecting File from the Ribbon and then selecting Show Document Panel from the Properties drop-down to the right of the Backstage area. InfoPath and SharePoint can be used to create custom DIPs that will appear in Office applications when a document is opened from within SharePoint. Data entered into these panels can be stored as metadata with the document in SharePoint. You will create a custom DIP later in this chapter.

Understanding Security Considerations

Security is a complex topic when working with InfoPath forms because a form will often touch many resources outside the form. InfoPath forms can contain data sources that retrieve data from databases, web services, or other locations. Each of these interfaces may require its own authentication and authorization mechanism in order to function properly. Form templates may also contain managed .NET code that can access files on the user's system or perform other potentially dangerous actions.

To control the use of these features, InfoPath has form security levels. Each security level places a different set of restrictions on what actions the form template can perform. The form-filling environment also affects what actions a form can take. Forms running in InfoPath Designer or Filler have greater freedom than those running in a web browser. A comprehensive discussion of the rules governing the restrictions placed on forms at different security levels is beyond the scope of this book, but a general description of these levels follows.

Restricted Level

Forms running in Restricted mode cannot communicate with resources outside the form template's definition. This is the most secure, but least functional, mode in which a form can run. There are many InfoPath features that will not function in a Restricted mode form. The following is a partial list of the features that can't be used in this mode and a brief description of why they are not allowed:

  • ActiveX controls: These controls run in a nonmanaged execution environment, where their actions cannot be limited.
  • Roles: Role definitions require information about the user that is not part of the form's template.
  • Data connections: Data connections access information that is external to the template. An exception to this rule is when submitting a form via e-mail. Submitting a form via e-mail is allowed because e-mail forms are the primary use of restricted forms.
  • Workflow forms: Data must pass in and out of workflow forms, which violates the restriction.
  • .NET managed code: Managed code will not load in a Restricted form because the .NET runtime is not available. The form will still load, but none of the .NET code will execute. No error will be displayed. This allows a template to use .NET code when running in InfoPath Filler while still functioning without code in a web-based form.

Because any form template that is deployed to SharePoint is, by definition, communicating with SharePoint, Restricted mode forms cannot run in SharePoint. Restricted mode forms are generally used for e-mail forms, where security limitations are extremely tight.

Domain Level

The Domain security level is the most commonly used mode for InfoPath forms in SharePoint. This level is an intermediate step between Restricted forms and those requiring Full Trust (which you'll learn about next). Domain mode forms can access external data as long as that data is accessible according to the domain's security zone as defined by Windows Internet Explorer.

images Note It is important to recognize that InfoPath's use of the word domain is not the same as a domain in Active Directory or in Internet web addresses. For example, the Internet addresses www.microsoft.com and office.microsoft.com may or may not represent different security domains depending on the configuration of zones in IE on the user's system.

When a form is opened from a SharePoint list or library, it is running as a URL-based form. The URL used to open the template is checked against the security zones defined on the user's desktop to determine whether it is in the Internet or Local Intranet zone. In Domain mode, external resources are restricted based on their zone relative to the zone of the form template.

InfoPath's security model also defines a URN-based form that maps to the Local Computer zone. However, SharePoint-based forms are always URL-based, so we don't cover URN-based forms in this book.

Full Trust

The most permissive level of security for an InfoPath template is Full Trust. In Full Trust mode, a form can access any resources that the person filling out the form can access. This may include databases, files on the local hard drive, and Registry settings. Obviously, Full Trust forms should be used only when absolutely necessary because of their potential for unintended impacts to the user's system.

The good news is that forms cannot get Full Trust just by asking for it. In fact, it can be quite difficult to get a form template installed in a way that allows Full Trust. In order to run a form in SharePoint using Full Trust, the form must be digitally signed using a trusted root certificate and it must be installed by a farm administrator through SharePoint's Central Administration site. The form can't be directly published by the designer.

Note that Full Trust does not eliminate any of the limitations on a web-based form. A web-based form running in Full Trust must still refrain from using features that are not supported in such forms. Making a form require Full Trust simply opens up new communication options.

Configuring Security Levels

A form's security level is configured in the InfoPath Designer application when it is designed. By default, InfoPath determines the correct security level for the form based on the features used in it. When the designer adds a data source, for example, the form will automatically be promoted out of Restricted mode.

To set a specific security level for a form, select the File tab in the Ribbon to open the Backstage area. Select Form Options and go to the Security and Trust area in the Form Properties dialog box. This panel allows the designer to set the security level and, if desired, sign the form template.

Creating Form Templates

InfoPath forms run the gamut, from very simple forms that collect a few fields, to highly complex data entry applications with multiple views, data connections, and complex business rules. This section presents the things to consider when creating forms for use in SharePoint.

Planning

The first step is, of course, to plan the form you are going to create. Taking a few extra minutes up front to organize the presentation and functionality of a form can make a big difference to the end user.

Security and Filling Environments

When designing a form, you have to consider the security level that the form will need to run at and the environment the user will be expected to use when filling out the form. For security levels, Table 11-1 lists some rules of thumb.

images

Remember to consider the desktop environment of the user who will be filling out the form and the features required by the form. If the user does not have InfoPath Filler on their desktop, your form must be web-enabled and forgo using any features not supported in web-based forms.

Data Connections

As with any data entry application, when designing InfoPath forms, you must consider where data is coming from and where it is being stored. In InfoPath, these become the data sources or connections.

The form's primary data source is the XML document that represents the data entered into the form. The data for this form generally gets written to a data store when the form is saved or submitted. In the case of SharePoint forms, the primary data connection is usually to a document in a document library or a list item.

Secondary data connections may retrieve data from databases, web services, or other SharePoint locations. The important thing is to ensure that whatever security credentials are needed to access that data are available in the intended filling environment. For example, a SQL Server connection string for a database connection can contain a password only if InfoPath Forms Services has been configured to allow it. A best practice for data connections is to use a data connection library to house a set of shared connections. These connections provide a level of trust that makes it easier to move and reconfigure form templates in SharePoint.

Using form templates in SharePoint also introduces two new data considerations: promoted values and web part parameters. When a form is published to a form library, it can expose some of the values from the form to the SharePoint environment. This allows users in the SharePoint environment to search and sort on data within the form without the need to open each form in the library. Using the new InfoPath Form web part on a web part page allows the form to interact with other web parts on the page through web part properties. When publishing a template, form values can be exposed as input, output, or input/output parameters from the web part the form is hosted in. This allows other web parts to feed data into an InfoPath web form and to receive values from it.

Roles

InfoPath roles are similar to audiences in SharePoint Server. Using a set of rules, the user filling out the form is assigned to a set of roles. Depending on which roles the user has, the form can be customized to show a different view or set of functionality.

Roles are not intended as a security feature because the user still has the ability to view the raw XML document after it is stored. Hiding information on the form template won't protect it after it is written to a form library or a disk file.

Another limitation of roles is that they work only in InfoPath Designer or Filler. Web-based forms cannot use roles. This limits their usefulness in SharePoint sites where web-enabled forms are preferred.

Views

InfoPath form templates can contain multiple pages, called views. Every template starts out with one default view. Additional views can be added that present the form's data in different ways. Each view can have its own layout and style. A view does not need to display all of the form's data. Like roles, views should not be used as a security feature. Some common reasons for using multiple views in forms include the following:

  • To simplify a large form by splitting it up into more-manageable pages
  • To create a print-friendly view of the report
  • To show different data to different users based on their role or the current state of a business process

Adding Behavior

In this context, behavior refers to any action taken by the form that isn't a direct response to a user action. This includes field validations and calculations that occur within the form beyond the controls' normal abilities to accept input. InfoPath contains multiple mechanisms for implementing custom behavior in forms.

The simplest way to implement behavior in a form is to use rules. Rules are a declarative way to indicate what the form should do in response to certain events. Rules are either validation, formatting, or action rules. A rule may have a condition that must be met and a set of actions to take in response to the event. For example, a rule could be triggered when the Budget field is greater than $100,000. The resulting action could be to set the Approver field to CFO. InfoPath also contains a formula language that can be used to define calculations directly in some situations instead of using rules.

There are some types of logic that need to be written in a full-featured programming language. InfoPath supports writing managed code, using VB.NET or C#, that runs in the .NET runtime. Forms that run .NET code must run in either the Domain or Full Trust security level. Because .NET code has the ability to do a great deal of damage and consume a lot of server resources, InfoPath has been designed to control its use by using SharePoint's “sandbox” approach.

images Caution Previous versions of InfoPath supported writing business logic in scripting languages such as JScript and VBScript. This functionality is now deprecated in favor of managed .NET code.

SharePoint Server 2010 contains a new system for hosting untrusted code in a safe, reliable way. Code running “inside the sandbox” is executed in a separate process from the rest of SharePoint. This prevents it from interfering with the server's basic functions and allows the farm administrator to limit the amount of server resources such code can consume. Sandboxed code can access only a subset of the .NET Framework that has been designed to prevent untrusted code from causing problems. This subset excludes connecting to databases, accessing files, or calling unmanaged code. For a more complete discussion, see the TechNet article at http://technet.microsoft.com/en-us/library/ee704541.aspx.

Web-enabled InfoPath forms always have to be able to run in the sandbox. They run in Domain security mode and can access only SharePoint resources that are within the site collection where they are deployed. Any .NET code they contain must adhere to the limitations of a sandboxed application. .NET code in InfoPath can access the InfoPath object model through a set of API calls. There are two versions of the DLLs containing these calls. One is a subset of the other and contains only those features that are valid for use in a sandboxed form. The references to these DLLs are set correctly depending on the compatibility settings for the form. A form that is set to be web-compatible will automatically bind to the more limited object model and .NET Framework classes.

images Tip There is a subtle but important difference between a form running sandboxed .NET code and one running no code at all. A form running without code runs within the security context of the user accessing the web site. A form running sandboxed code runs in a separate sandbox service process. As a result, such a form will be unable to access the identity of the user after the form is open. The InfoPath username() function is designed to resolve this problem. It will return the correct username even when the form is running in the sandbox.

A form that cannot live within the restrictions of a sandboxed form can still be used within SharePoint. In that case, the form must be set to Full Trust and be published by a farm administrator. Also, because web forms must be sandboxed, Full Trust forms must be filled out by using InfoPath Filler, not a web browser. As a result, the fully trusted code runs on the user's desktop, not on the SharePoint server.

Publishing Templates

After the form template is complete, it needs to be published. A published form is more than just a copy of the form in a particular location. Think of publishing a form as compiling a computer program. After the template is published, it is ready to be used for filling out forms.

There are various ways to publish InfoPath forms, including publishing to network file shares, local directories, and as installable executable files (MSI). However, these do not apply to SharePoint and therefore are not discussed here. The options for publishing form templates to SharePoint include publishing to form libraries, content types, and farm deployments.

When a form is published directly to a SharePoint document library (called a form library when using forms), the template becomes the document template for the library. When the user creates a new document in the form library, the form is launched for the user. The form template is stored in the site directory housing the library. The template is used only by that library and is maintained separately from any other form templates in the SharePoint environment.

Instead of publishing directly to a form library, the template can be deployed as a content type in SharePoint. In addition to the form template, the site content type can define data fields, workflows, and information management policies such as retention rules. A content type can be used multiple times throughout the site collection. This simplifies maintenance for a widely used template because there is only one central copy to be updated when a change is made.

A form template can also be published at the farm level by a farm administrator. This places the template in a centralized, trusted, farmwide repository. Deploying form templates at the farm level allows them to access certain capabilities that are not available to templates at the site collection level. A farm-level template can be used by a library or content type housed in any site collection in the farm. Only a farm-level template can run in Full Trust mode, allowing it to access any data source and execute unrestricted .NET code.

Building InfoPath Forms for SharePoint

Now you will do some hands-on work, using InfoPath forms to augment the design of your SharePoint site. You will create a web-enabled form, customize the data entry forms for a list, and create a document information panel for a new project management office within your organization.

Before proceeding through these exercises, be sure to do the following:

  • Ensure that InfoPath Forms Services is up and running in your SharePoint environment.
  • Create a new site to work in. Any site template will work. This example uses a blank team site in a new site collection.
  • Be sure that the SharePoint Server Enterprise Site Collection Features option is activated in your site collection.
  • Install the InfoPath Designer 2010 client application on your workstation.

images Tip For more information on configuring InfoPath Forms Services, see the TechNet article at http://technet.microsoft.com/en-us/library/cc262263.aspx.

EXERCISE 11-1. CREATE AN INFOPATH FORM FOR USE IN A FORM LIBRARY

EXERCISE 11-2. CUSTOMIZE LIST FORMS BY USING INFOPATH

EXERCISE 11-3. CREATE A DOCUMENT INFORMATION PANEL

Summary

In this chapter, you have

  • Explored the concepts of InfoPath 2010 forms
  • Examined the security and functionality considerations associated with browser-enabled forms in InfoPath
  • Learned how to create and deploy InfoPath forms to a SharePoint environment
  • Customized the new, display, and edit forms for a SharePoint list by using InfoPath
  • Created a document information panel and deployed it in SharePoint to collect custom document metadata
images

Figure 11-37. Using InfoPath forms in SharePoint

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

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