Microsoft SharePoint: Recipes for Automating Business Processes

(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.

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

Using the Collect Feedback workflow to receive feedback on a Microsoft Word 2010 document

SharePoint 2010 provides a number of workflows ready to use out of the box. In this recipe, we learn how to use the collect feedback workflow to get feedback on a Microsoft Word 2010 document.

Getting ready

This recipe works for:

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

You will need a document library to attach the collect feedback workflow to. You will need a document in that document library to run the collect feedback workflow against. This recipe uses a SharePoint 2010 Team Site with a Sales Proposals document library added for illustration.

How to do it...

  1. Open Internet Explorer and navigate to your SharePoint 2010 Team Site.
  2. Select the Sales Proposals list from the Quick Launch menu.
  3. Select the Library tab of the Library Tools ribbon.
  4. From the Workflow Settings button, activate the Add a Workflow option.
  5. Select the Collect Feedback – SharePoint 2010 template from the Select a workflow template: list.
  6. Name the workflow Sales Proposal Feedback Workflow.
  7. Set the Select a task list: drop-down to Tasks.
  8. Set the Select a history list: drop-down to Workflow History (new).
  9. Ensure that the Allow this workflow to be manually started by an authenticated user with Edit Item permissions checkbox is ticked.
  10. Click on the Next button.
  11. The workflow association form is displayed. Enter the text Please provide feedback on this sales proposal in the Request textbox.
  12. Set the Duration Per Task to 5.
  13. In the End on Document Change row of the form, ensure that the Automatically cancel the workflow if the document is changed before the workflow is completed checkbox is ticked.
  14. Click on the Save button.
  15. Open the Sales Proposals Library and select the document that you wish to run the Collect Feedback workflow on.
  16. Select the Workflows button from the Library tab of the Library Tools ribbon.
  17. Click on the Sales Proposal Feedback Workflow hyperlink in the Start a New Workflow section.
  18. The workflow initiation form is displayed. Enter the users who you want to collect feedback from. Set the Order drop-down list to All at once (parallel).
  19. If you require any users to be copied in on the progress of this workflow, then add their details to the CC box.
  20. Click on the Start button to start the workflow.