InfoPath is a great forms designer, and in my consulting, a lot of users are able to start developing their own solutions quickly. Here are three quick tips to help add a little shine to your first InfoPath forms:
• Adaptive forms – showing or hiding sections as needed based on other form input
• Standardizing form names when
• Using SharePoint views as secondary data sources
Adaptive forms
It’s pretty simple to show or hide sections of an InfoPath form. The trick is to add a “section” control from the standard toolbox.
• Add an option button or check box control outside the section. (If you put the field inside the section, you won’t be able to use the field to toggle the view once the section is hidden.)
• Drag the fields or layout tables you want to selectively show or hide into the section.
• Open the properties dialog for the section.
• Select the Display tab and click Conditional Formatting button.
• Set up the condition for when the section should be hidden, and check the hide this control box.
Automatic Naming for Submitted forms
When users finish filling out the forms, they need to figure out a unique name for the form. For commonly used forms, it’s usually best to standardize the form naming.
• From the Menu bar, select Tools | Submit Options
• Click the Add button
• Create a New Connection to Submit Data
• Specify the URL to the Forms Library
• Use the concat function to develop a unique file name format. Concat adds all the arguments into a single string. You probably want to use some combination of the submission time and the form fields to generate a meaningful, unique name.
Also, on the Submit Options screen, it’s a good practice to close the form after submission – otherwise users are left in the form and may think they need to save (which asks them for a file name again, leading to confusion.)
Using SharePoint List Views as Secondary Data Sources
It’s not uncommon for InfoPath forms to use dropdown lists that correspond to an existing SharePoint list. The problem for most lists is that they may contain extra information that needs to be filtered, and may require custom sorts. You can use a native SharePoint list connection, but the data elements will be retrieved in their default sort order (the auto incrementing ID field in order of data entry).
Here, the trick is not to set up a connection to a SharePoint list, but to an XML “file”. The trick is to use a URL to a SharePoint web service. Here’s the format:
Substitute the following parameters:
• SITEURL: put in the full URL to the site (and sub site if needed). Do not include the list name or ASPX page.
• ListGUID: GUID for the SharePoint List
• ViewGUID: GUID for the SharePoint List View
You can get the GUIDs for the list and view by opening up the view properties and inspecting the URL for the properties screen. You will see a section of the URL that reads, for example:
List=%7B7FA90930%2D2C35%2D4505%2DA077%2D6E381C0C6382%7D
You need to convert this into appropriate formats with brackets (%7B and %7D) and dashes (%2D):
{7FA90930-2C35-4505-A077-6E381C0C6382}
The same technique works in both MOSS 2007 and SharePoint 2010. You can test the URL in a browser, which should return an XML page that resembles:
- <xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
- <s:Schema id="RowsetSchema">
- <s:ElementType name="row" content="eltOnly" rs:CommandTimeout="30">
- <s:AttributeType name="ows_Attachments" rs:name="Attachments" rs:number="1">
<s:datatype dt:type="boolean" dt:maxLength="1" />
</s:AttributeType>
- <s:AttributeType name="ows_LinkTitle" rs:name="Product" rs:number="2">
<s:datatype dt:type="string" dt:maxLength="512" />
</s:AttributeType>
- <s:AttributeType name="ows_Company" rs:name="Company" rs:number="3">
<s:datatype dt:type="string" dt:maxLength="512" />
</s:AttributeType>
</s:ElementType>
</s:Schema>
- <rs:data>
<z:row ows_Attachments="0" ows_LinkTitle="Another one" ows_Company="Mine" ows_Therapeutic_x0020_Area="Oncology" ows_Phase="I" ows_MarketPotential="Medium" ows_Status="Active" />
<z:row ows_Attachments="1" ows_LinkTitle="Codename" ows_Company="Classified" ows_Therapeutic_x0020_Area="Pain" ows_Phase="II" ows_MarketPotential="High" ows_Status="Dormant" ows_Corp_x0020_Overview="<div>To be developed</div>" ows_More_x0020_Information="http://intranet/sample.doc, http://intranet/sample.doc" ows_AnnualRevenueEstimate="1000000.00000000" />
<z:row ows_Attachments="0" ows_LinkTitle="Newest Product" ows_Company="rrr" ows_Therapeutic_x0020_Area="Pain" ows_Phase="III" ows_MarketPotential="Medium" ows_Status="Dormant" ows_Corp_x0020_Overview="jjjj" ows_AnnualRevenueEstimate="1000000.00000000" />
</rs:data>
</xml>Good luck!