Thursday, January 26, 2012

Basic and Advanced Forms for a Single List

Included here, is an old post I began working on at my previous employer while we were researching the usefulness of Infopath 2010. I was unable to finish this post, before transitioning from then to now. As such, I am posting this incomplete blog, as is, so that it might help others realize the full value of Infopath 2010 in their SharePoint projects.

The article is topic complete, all it is really missing is the screen captures to go along with the content...

BEGIN

One great tool that Infopath 2010 offers is different views for the same form. By using two views we can build a form with basic and advanced data entry versions. For this lab I created a list that has seven custom fields. Three number fields for ratings, and a text field for comments.

My intention is to make a simple survey where a user can quickly rate the overall presentation. I also want an optional advanced form to give the presentation seperate overall, content, and presenter scores, as well as leave comments.

After creating the list I have this form by default:

{Picture of Default Form}

As you can see, there are some changes that need to be made. The Title field isn't particularly useful, so I want to automatically fill it with some anonymous data, (See Making Title Fields More Useful with InfoPath 2010). Secondly, I want to keep the function of the number fields, for reporting and metrics, but change their appearance.

I start by customizing the form in InfoPath 2010.

{Picture of InfoPath before customizations}

First I select and delete the entire layout. Here are the customiations:
  • Create a centered page layout with a title, and call it "Rate this Presentation"
  • Add a two column table
  • In the first row, right column, add a custom 3x1 table and set the width of each column to 150px
  • Drag the Overall Rating field control into the first cell of the 3x1 table
  • Delete the label text above the field control
  • Change the control type to a option button
  • Copy and paste the button into the two remaining cells of the 3x1 table
  • Set the properties of the buttons such that the first one's value is 0, the middle to 1 as default, and the right one to 2
  • Enter "Overall Rating" in the label area
  • Use "below expecations," "met expectations," and "exceeded expectations" as descriptive text next to each option button
  • Delete remainint rows of the main table
  • Add two buttons to the form called "Advanced" and "Submit" respectively
The form should look something like this:

{Picture of WIP Form}

Now we need to create a new view for the advanced version of the form. Start by clicking "New" in the Views section of the Page Design tab.

{Pic of the New View button in action}

I called my new view "Edit item (advanced)." Copy the contents of the default view into the advanced view to use as a starting point. Here are the rest of the edits:
  • Add three rows to the main layout table
  • Create "Content Rating" and "Presenter Rating" controls similar to the existing "Overall Rating" control (Short-cut! Copy and paste the existing table and controls and just change the binding property to the correct field)
  • Add the Comments field controls to the last row of the layout table
  • Change the "Advanced" button to "Basic"
The new view looks something like this:

{Picture of the advanced view}

Now we need to connect the rules to the buttons. Switch back to the basic (default) view and bring up the rules manager for the "Advanced" button. Add a new action rule to tbe button and give it a name, "Advanced Clicked" will do. Add an action to switch views to the "Edit item (advanced)" view. Verify that the Submit button is set to submit the form.

{Picture of switch item rule dialogue}

All that remains is to configure the basic button on the other view. Switch to the advanced view and add a new rule to change views back to the default edit item view. Double check that the Submit button is submitting the form and we're all set to publish the form to the list.

Here is what my advanced form looks like in SharePoint:

{Picture of finished advanced form}

You might notice that whatever you set "Overall Rating" to is maintained when you switch between basic and advanced forms. Indeed, all the fields values are kept and saved on submit, even when not shown in the form. This hints at the possibility of building a multi-page form to fill out a complex list entry - but I think I'll save that for another time.

END