28 Feb 2012

Building SharePoint Applications with InfoPath 2010

Contents

  • SharePoint Server 2010 Application Architecture
  • Best Practices for InfoPath SharePoint Applications

SharePoint Server 2010 Application Architecture

Figure 1. Architecture decision tree for a SharePoint application that uses InfoPath 2010
Architecture decision tree

Choosing Whether to Use InfoPath 2010

  • Microsoft Word 2010 documents
  • Microsoft Access 2010 forms
  • Microsoft ASP.NET Web Forms
Application recommendations depending on the solution type
Solution Type Recommendation
Simple complexity, form data that is stored as client files Word
Simple complexity, form data that is stored as list items InfoPath
Moderate complexity, without workflow Access
Moderate complexity, with workflow InfoPath
High complexity ASP.NET
Selecting the Right InfoPath Form Template
  • Two options: Form Library Template, List Template.
  • You can publish such a form template directly to a form library or as a site content type.
Comparing form library and list templates
Question Form Library Template List Template
What is the structure of the form data? Hierarchical Flat
How is form data stored? XML files List items
Is there support for custom code? Yes No
What offline client is available? InfoPath filler SharePoint Workspace
Is there support for digital signatures? Yes No
Understanding the Form Structure
A form that uses this schema lets users make a single hardware selection. There are no nested or repeating elements, unlike the next XML structure.
<Request>
    <RequestID>f94a566d-1581-49bd-abf7-bcad68e8c0b3</RequestID>
    <RequestDate>2010-03-24</RequestDate>
    <Requestor>Karen Berg</Requestor>
    <RequestorManager>Holly Holt</RequestorManager>
    <HardwareType>Keyboard</HardwareType>
    <HardwareName>Coho Writer K9</HardwareName>
    <HardwareModel>CO K9 NOP</HardwareModel>
    <HardwareSpecs>Black, USB; Ergonomics Design; 104 Normal Keys; 9 Function Keys</HardwareSpecs>
    <HardwareCost>14.99</HardwareCost>
    <RequestStatus>New Request</RequestStatus>
    <RejectionReason></RejectionReason>
</Request>

If your form has a simple, flat structure, as is the case with the former XML example, then a SharePoint list template is probably sufficient. Each individual XML element maps well to a single SharePoint column.
By using the latter XML example, the user can select multiple hardware items, which will likely be displayed in a repeating table control in an InfoPath form. A SharePoint list form does not support nested or repeating elements. In this case, you would select the SharePoint form library template. This enables you to build a more complex data structure in the InfoPath designer.
<Request>
    <RequestID>f94a566d-1581-49bd-abf7-bcad68e8c0b3</RequestID>
    <RequestDate>2010-03-24</RequestDate>
    <Requestor>
        <DisplayName>Karen Berg</DisplayName>
        <Email>karenb@contoso.com</Email>
    </Requestor>
    <RequestorManager>
        <DisplayName>Holly Holt</DisplayName>
        <Email>hollyh@contoso.com</Email>
    </RequestorManager>
    <RequestedHardware>
        <HardwareItem>
            <HardwareType>Keyboard</HardwareType>
            <HardwareName>Coho Writer K9</HardwareName>
            <HardwareModel>CO K9 NOP</HardwareModel>
            <HardwareSpecs>Black, USB; Ergonomics Design; 104 Normal Keys; 9 Function Keys</HardwareSpecs>
            <HardwareCost>14.99</HardwareCost>
        </HardwareItem>
        <HardwareItem>
            <HardwareType>External Hard Drive</HardwareType>
            <HardwareName>Proseware BigStore</HardwareName>
            <HardwareModel>PRO LA33-3321</HardwareModel>
            <HardwareSpecs>USB 2.0 Interface; 5400 RPM; 80 GB Hard Drive; 2.5-inch Form Factor; WD Synchronization and Encryption</HardwareSpecs>
            <HardwareCost>96.99</HardwareCost>
        </HardwareItem>
    </RequestedHardware>
    <TotalCost>111.98</TotalCost>
    <RequestStatus>New Request</RequestStatus>
    <RejectionReason></RejectionReason>
</Request>


Understanding the Storage Model
  • Creating new field in a form with an InfoPath SharePoint List form template, you are creating a column in the SharePoint list associated with that form template.
=> Data are stored as SharePoint list items, not have an XML representation.
  • Conversely, a form you create using an InfoPath SharePoint Form Library template is in fact an XML file will be stored in a SharePoint form library. You can still map a field in a form library template to a SharePoint column.
Adding Custom Code: this file is packaged with the form template when the template is deployed. If your code does not access files and settings on the target computer, your form template can have a domain trust level. With domain-level trust, you can publish directly to a form library. However, if the custom code does have access to files and settings, the form template must be fully-trusted and uploaded to InfoPath Forms Services by a server administrator.
Supporting an Offline Work Environment
Ensuring Data Integrity with Digital Signatures

Best Practices for InfoPath SharePoint Applications

1- Form Views
  • InfoPath 2010 uses XSLT to transform the form's XML data source into editable HTML. Each form view in a template has its own associated .xsl file. From a performance perspective, it is better to have many form views than a single view that contains all of the template's business logic.
  • To prevent a view from appearing in the View menu
  1. In the ribbon, click the Page Design tab.
  2. In the Views group, click the View list and then click the applicable view name.
  3. Click Properties.
  4. In the Views group, click the View list and then click the applicable view name.
  5. In the View Properties dialog box, clear the Show on the View menu when filling out this form check box. (By default, this check box is selected.) Figure 4 shows the check box cleared.
28.1
2- Data Connections
  • Multiple data connection queries in the Loading event of your form can adversely affect performance. By default, InfoPath sets data connections to automatically retrieve data when the user opens a form.
When you create the data connection, verify that you clear the Automatically retrieve data when form is opened check box in the Data Connection Wizard, as shown in Figure 5.

Data connection wizard dialog box
  • Another consideration is to convert an external connection that stores static data into an XML file. You could then include the XML file as a resource file in the form template, which avoids the need for an external query.
3- Controlling Server Postbacks
Most form controls have a postback setting that determines when a post to the server will occur. => frequent server posts that occur in a form will result in poorer performance.
By default, a control's postback setting is Only when necessary for correct rendering of the form. => If the data that was entered for a control never must be sent to the server, you should configure the setting for that control to Never.
Text Box Properties dialog box
4- Enabling List Filtering
Filtering is a declarative means of limiting options that are displayed in certain controls, such as drop-down list boxes. The filtering feature in the InfoPath designer enables you to have a cascading set of drop-down list boxes. When a user selects a list option, that selection affects the options that are shown in a related drop-down list. For example, in a hardware request scenario, you could have a drop-down list for the hardware type, such as an external hard disk drive, keyboard, or mouse. A second drop-down list for models would show only the model numbers associated with the selected hardware type. Then, when a user selects a model number, you could use declarative rules to set corresponding fields in the form (for example, the hardware cost).
5- Adding User Information to a Form:
In the SharePoint application, if email messages are sent to a user or tasks are assigned by a SharePoint workflow, your form must include that user information.
Whether you are trying to determine the form initiator or gather information about approvers, reviewers, or other roles for your scenario, InfoPath 2010 offers two common approaches for adding user profile data into a form:
  • Person/group picker control _ The easiest way.
  • User Profile Service
http://Web application/_vti_bin/userprofileservice.asmx

6- Workflow Considerations
To promote a field in a SharePoint form library template
  1. In the ribbon, click the File tab.
  2. In the Info area, click Form Options.
  3. In the Form Options dialog box, click the Property Promotion category.
  4. In the Column Name area, click Add.
  5. In the Select a Field or Group dialog box, click a node.
  6. In the Column name box, set the name of the SharePoint column for the selected field. Figure 10 shows an example of a field being promoted
Promoting fields as SharePoint columns
Select a Field or Group dialog box
7- Security and Trust
  • Restricted — The form cannot access content outside the form. Any data connections used must be embedded as resource files in the template.
  • Domain — The form can access content from the domain in which the form is located. The form can use custom code as long as the code does not access files and settings on a user's computer.
  • Full Trust — The form has access to files and settings on the computer. For a fully-trusted form to run in the InfoPath filler, you must install or digitally sign the form with a certificate.
8- To convert a data connection into a UDC file and then add it to an existing data connection library
  1. In the ribbon, click the Data tab.
  2. In the Get External Data group, click Data Connections.
  3. In the Data Connections dialog box, click the applicable data connection and then click Convert to Connection File.
  4. In the Convert Data Connection dialog box, specify the URL for the new UDC file (a .udcx file), which will be stored in an existing data connection library. Figure 11 shows a sample URL for a new UDC file.
Converting a data connection to a UDC file
Convert Data Connection dialog box
9- Form Submission
To let a user submit form a file to a library, web service, or some other location, you must enable the submit functionality in the form template.
On the Data tab in the ribbon, you can click Submit Options to enable submit operations. You can also define the submit data connection that the form template will use. When creating the data connection, you must define the naming convention for form files in the Data Connection Wizard. Typically, you would concatenate form fields and possibly include a time stamp in your naming convention. If your solution includes a SharePoint workflow, you can have your workflow define the naming convention by using the Document ID Service. The Document ID Service, which is enabled at the site collection level, assigns unique IDs to items in lists and libraries throughout the site collection.

3 comments:

Anonymous said...

nice

Anonymous said...

Great ! I am highly impressed with the information that you have shared in this post. You have explained the complete application architecture in detail and also how to choose the right template based on the requirements.
sharepoint electronic signature

Shopee said...

:) Infopath is a powerfull tech to collect, process data and use for printing.