Monday, September 10, 2012


This blog has been migrated and consolidated under

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


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.


Friday, June 25, 2010

FBA Users in SharePoint 2010

One of our sites scheduled for upgrade to SharePoint 2010 uses Forms Based Authentication (FBA). Various blogs can be found on how to set up SharePoint 2010 to connect to a FBA database. But, one critical difference is how the new Claims Based Authentication (FBA in SP2010 speak) hands over an Idenentity to SharePoint 2010.

The change from integrated security to a Claims Based is basically this: In Claims Based mode, the SharePoint site no longer handles verifying Identities; that is handled through the new Security Token Service (STS). Previously a user's integrated FBA Identity was something like "FBAMembership:EtherDragon" now, in 2010, the STS hands over my Identity with something like "i:0#.f|FBAMembership|EtherDragon" and, as far as 2010 is concerned, that is a different user.

The fix was to write a quick Web Part for 2010 that replaces all FBA user Identities in all groups with the correct STS one.

Here's some code:
SPWeb oWeb = SPContext.Current.Web;

foreach (SPGroup myGroup in oWeb.Groups)
string wrongFormat = "fbamembership:";
SPUserCollection myUsers = myGroup.Users;
List usersToDelete = new List();

foreach (SPUser userCandidate in myUsers)
if (userCandidate.LoginName.Length >= wrongFormat.Length)
if (userCandidate.LoginName.Substring(0, wrongFormat.Length) == wrongFormat)

foreach (SPUser myUser in usersToDelete)

string loginName = "i:0#.f|fbamembership|
" + myUser.LoginName.Substring(wrongFormat.Length);
string eMail = myUser.Email;
string name = myUser.Name;
string notes = myUser.Notes;

myGroup.AddUser(loginName, eMail, name, notes);
(End Code)

Without this little code block, we would have had to go through about 2000 user entries in various groups to remove and replace the users through the SharePoint UI.

Wednesday, March 24, 2010

Making Title Fields More Useful with InfoPath 2010

One of the challenges 4QTRS has had was determining how to best use the “Title” field in a given SharePoint list. Many lists, such as “Tasks” can use “Title” very naturally, using the title to give a few words to describe the item; i.e. “Run Server Updates.” But, other titles don’t make a lot of sense. “Last Name” is a field that can be adapted for the title field, indeed, the contact list changes the title field display name to “Last Name” for readability.

Consider a simple in/out log. The list leverages the already existing “Created By” field to determine who records in/out status, as well as the existing “Created” date/time field to log the in/out change. In this case, having a person enter anything into the “Title” field would be superfluous and open the process up to errors. So, we’re going to have the form automatically populate the title field and hide it from the user.

Start by opening up InfoPath 2010 and creating a new SharePoint List Form.


After authenticating to the site, and entering “InOutBoard” as the new list name, we see the default InfoPath form. Add a field called “Presence” and change the choices “In” and “Out” only.


Next, we will simplify the form to an easy two-button layout using the InfoPath designer. Our new buttons will each have a rule that runs on click that will handle all the work for us, including making sense of the otherwise useless title field.

Start by wiping the form, and creating a new centered layout section. Place a simple table within the layout and add two buttons; one each in the left and right cells. Change the buttons to read “In” and “Out” and delete the remaining table rows. Your form should look like this:

Now, we need to add four rules to the In button to complete the data entry.
  1. Set a field’s value: Presence = “In”
  2. Set a field’s value: Title = concat(userName(), " In at ", now())
  3. Submit using data connection
  4. Close this form

Configure a similar set of rules for the Out button, changing the two occurrences of the word “In” to “Out” and publish the form.

Click the Add new item link bring up the new form. We can click either button to enter an in/out log item into the list. Most importantly, the title field populates with useful information; “etherdragon In at 2010-03-24T11:25:39”

Improving the form further by changing the simple buttons to image buttons. Here is my finalized form using two simple image buttons.