Interesting facts abut InfoPath and SharePoint Lists

Design First

If you start out creating a normal Blank Form template and then afterwards realize that you want to submit the form data to a SharePoint list, you will have to recreate your form template as a SharePoint List form template. Be aware of this and decide beforehand what your form template is going to be used for and how it is going to be submitted. By default, a field in a SharePoint form library template is not available as a SharePoint column. Any fields in a library template must be promoted as a SharePoint column if you wish to use in workflows and other scenarios.

This is handy for a Form Library Form. In the ribbon, click the File tab, In the Info area, click Form Options.

Try to keep the security level of your template at the domain level. Having domain-level security will make the solution more user-friendly and ease maintenance for the form developer.

You can convert an external connection that retrieves data from outside the domain (such as a database) into a Universal Data Connection (UDC) file, which stores connection information. You can then store the UDC file in a data connection library that resides in the same domain in which you publish form template. You can then access the UDC file exactly like any other data connection.

The difference between the Main and secondary data sources

The Main data source of a form contains the data that you want to permanently store when you save the form. A secondary data source is a temporary storage location for data that is external to the form which typically lives outside the form in databases, XML files, SharePoint lists or libraries, or can be retrieved from web services.  When you save a form, the data in the secondary data sources of the form is never saved in the form. the Main data source is locked from modifications when you create a SharePoint List form template.

Repeating tables

An easy way to bind the Secondary data source for a SharePoint list to a repeating table is to drag-and-drop the repeating group that is located under the dataFields group in the Secondary data source from the Fields task pane onto the form template, To bind the SharePoint list to a repeating section, select Repeating Section with Controls from the context menu instead of Repeating Table.

Promoting fields as SharePoint column: Any repeating node in the form template that is promoted as a SharePoint column has aggregate functions associated with it. For example, if you were to promote the HardwareCost node that is nested in the repeating HardwareItem group, you could use one of the following functions:

  • First — Promotes the first occurrence of the node
  • Last — Promotes the last occurrence of the node
  • Count — Promotes the total number of the nodes
  • Merge — Promotes a concatenation of all the node values
    Note: A promoted column is, by default, read-only to external processes such as a workflow. To enable editing for a promoted column, you must configure the column properties at the time that you publish the form template.

 

Two ways to create list forms in InfoPath, which way should I use

  1. From within InfoPath Designer 2010, when you go to create a new form template, use the SharePoint List form template to base your form template on and then link the template to a new or an existing list in SharePoint.
  2. From within SharePoint 2010, click the Customize Form button on the List tab on the ribbon when you’ve navigated to a SharePoint list.

    User Method 1 to create a form template from within InfoPath for more control because If you customize a form for a SharePoint list from within SharePoint, you will only be able to customize a SharePoint List form template to view/edit a single item.

    How to do method 1, create a new form for an existing list.
    Open Infopath 2010, click File > New > SharePoint List (double click) then enter URL to your site that contains your lists

image

 

This form pops up, choose Customize existing list, pick your list > Next

image

Choose Advanced options

image

Design Considerations for Performance

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 (each with a small amount of business logic, such as conditional formatting) than a single view that contains all of the template’s business logic. The XSLT transformation engine is taxed less if your .xsl file is not too complex.

By default, InfoPath sets data connections to automatically retrieve data when the user opens a form. For each connection in your scenario, you should consider whether you can delay a data query until the user executes some event by filling out the 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.

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.

Controlling Server Postbacks: Most form controls have a postback setting that determines when a post to the server will occur. As with other declarative logic, 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 on the text box properties.

There are known performance issues with cascading drop-down list boxes in a repeating table control. In Building SharePoint Applications with InfoPath 2010 (Part 2 of 2), there is a set of steps that shows how you can efficiently incorporate cascading list functionality into a form template that uses a repeating table.

User Profile Service to Add user information to your forms

Office SharePoint Server 2010 includes the User Profile Service, a web service that contains several operations for integrating with your organization’s Active Directory service. One operation in particular, GetUserProfileByName, enables you to pass an account name parameter to retrieve corresponding profile information. If you leave GetUserProfileByName blank when you make a query, the web service returns profile information for the current user. The default location for the web service is http://Web application/_vti_bin/userprofileservice.asmx. Figure 8 shows the URL being entered in the Data Connection Wizard. In Building SharePoint Applications with InfoPath 2010 (Part 2 of 2), there are steps that show how to retrieve current user and manager profile information from the User Profile Service.

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. Building SharePoint Applications with InfoPath 2010 (Part 2 of 2) describes how to include logic in a workflow that sets a file name based on a generated document ID.

Setting up the default user

Setting the default value of the Person/Group picker is done through the fields task pane. Show the fields task pane by selecting “Show Fields” on the data tab and expand your Person/Group picker field (in my case, outBy). Click “Show advanced view” to see the detailed view. Right-click on the AccountId and choose properties. Under default value, choose the function builder  and type userName().
Again, make sure that “Refresh value when formula is recalculated” is unchecked, so that this rule is only run once and not every time the form is opened. Click Ok. Repeat this process with the DisplayName (optional) to get the best experience. Now the people picker will default to the person who opens the form.

Advertisements