Microsoft SharePoint: Recipes for Automating Business Processes

5 min read

(For more resources on Microsoft Sharepoint, see here.)

Creating an InfoPath Form for a SharePoint List

You can replace the default SharePoint list forms with an InfoPath form on any SharePoint list. This gives you much more flexibility and control over how you edit and display the data.

Getting ready

This recipe works for:

  • SharePoint 2010 Enterprise Edition
  • Office 365 (SharePoint Online)

You will need a SharePoint List where you want to create an InfoPath form.

You will need the Design or Full Control permission level to run this recipe.

You will need InfoPath Designer 2010 installed on your client machine.

This recipe uses a SharePoint 2010 Team Site with a contacts list added for illustration.

How to do it…

  1. Open Internet Explorer and navigate to your SharePoint 2010 Team Site.
  2. Select the Contacts list from the Quick Launch menu.
  3. Select the List tab of the List Tools ribbon.
  4. Select the Customize Form icon.
  5. InfoPath Form Designer 2010 will open displaying an auto-generated InfoPath form for the contacts list.
  6. (Move the mouse over the image to enlarge.)

  7. Select the File tab in the ribbon to access the backstage view.
  8. Select the Quick Publish button.
  9. The InfoPath form is now published and replaces the default form on the SharePoint list. Click on the OK button in the Publish dialog displayed.

How it works…

When you create a SharePoint list, SharePoint automatically creates default edit, display, and new forms for you. While these forms are functional, they are somewhat limited in the presentation and customization options that they provide. If you have SharePoint Server Enterprise Edition installed, you replace these forms with an InfoPath 2010 form. InfoPath forms offer you many more options for creating and controlling how you edit and display your list data. This recipe demonstrates the mechanics of replacing the forms; once you have done this a whole range of new customization options is available to you. Every time you want to edit the form, just repeat this procedure.

One gotcha that you may run into is if you have added a taxonomy field (that is, one that shows a term set) to your list. Unfortunately these fields are not supported in the current InfoPath release, and you will receive an error when you try to edit the list form. It’s a big omission from the current version of SharePoint, and not one that there is an obvious workaround for.

There’s more…

Having run this recipe, you may be left thinking “so what?” However, once you have created an InfoPath form for your list, you have all the power of the InfoPath form designer at your disposal. You can now remove columns, add graphics, text, and business rules to the form to fit your needs. Techniques for performing these customizations are described in the following sections.

Removing columns

It’s quite common to have columns in a list that you don’t want the user to fill in. When you have an InfoPath attached to the list, simply open the form, delete the field that you don’t want the users to edit, and republish.

If you have used the table-editing tools in Microsoft Word, you will find the InfoPath experience very familiar. The following screenshot shows the Attachments row being deleted from the form:

It’s important to realize that you are only removing columns from the form, not from the underlying list itself. Also, if you add a new column to your list after you have customized the form, SharePoint won’t automatically add the new column to your form for you. It will prompt you that there are new columns available the next time you open the InfoPath form designer. Click on Yes to update the fields list.

You can then select the new fields that you require and drag-and-drop them into the form.

Adding images, explanatory text, and tooltips

Normal SharePoint list forms are a bit dull. Now that you have an InfoPath form, you can start to brighten things up. You can change colors, fonts, add images, text, and tooltips.

To add an image, use the Picture button on the Insert ribbon.

Then simply browse to the picture that you want to add and republish the form.

Adding text to your form can help guide your users when they are filling it in. You can add the text directly to the form or you can add it to the controls ScreenTip.

The ScreenTip text will only be shown when the user’s mouse hovers over the control in the browser. This helps your users without cluttering up your form.

Adding rules to validate data

InfoPath forms allow you to add rules. Rules can be added to the form to validate data, apply custom formatting, or perform custom actions. You can use actions to set field values, switch views, submit form data, and so on. InfoPath form rules are the way to implement and enforce custom business logic in your forms, so I advise you to invest some time learning how to build them up and exploring what they can do.

The following screenshot shows how to apply InfoPath built in e-mail validation rule to the e-mail textbox field. This rule uses a regular expression to ensure that the value entered is in a valid e-mail format, and shows a validation error if it is not.

InfoPath Designer versus InfoPath Filler

You may notice two Microsoft Office InfoPath programs on your computer, Microsoft InfoPath Designer 2010 and Microsoft InfoPath Filler 2010. When creating forms for use in SharePoint, InfoPath Designer 2010 is the application you need to use. InfoPath is a standalone forms technology, while InfoPath Filler 2010 exists to allow users to fill in InfoPath forms without the use of SharePoint. That isn’t something we cover in this book, though it’s useful to know that you can use this if you need to.

Subscribe to the weekly Packt Hub newsletter

* indicates required


Please enter your comment!
Please enter your name here