Sunday, February 16, 2014

InfoPath: Hidden Fields

I'm not a fan of having a form with fields that may not be used. Ideally, fields should only be displayed if They are needed. Take the new hire laptop request form, for example. Not all new hire laptops are shipped to the end user. Sometimes they are shipped to other offices or they stay here, in Seattle, to be picked up.

This means the Shipping Address remains empty. It leaves a rather large gap in the information on the form.


These fields should be hidden and should only show when the proper delivery method is chosen:

In SharePoint 2010, you need to use InfoPath to edit the form in order to hide unused fields. You can take the standard form and edit it to display exactly what you want to see.

Start by removing the fields you want hidden. (They will still be in the side bar.)
To add an Optional field, do the following:
  1. Open a new, separate InfoPath form.
  2. Drag the myFields folder from the Fields section on the right into the form itself.
  3. This creates a box called section (myFields)
  4. Click on the field to highlight and copy it.
  5. Move to your current list form and paste the field into both the name column and the field column. Example:

Unfortunately these fields are not editable because they have no association with the current form.
Right click on the field and select Change Binding…

Associate the section with the first field I'm planning on putting inside this area. In this case, it's the Shipping Address Primary Street Line.

Drag and drop the existing fields you wish to hide into the new section:

Then create a rule:
  1. Under the Home Ribbon select Manage Rules.
  2. Select the Section for editing.
  3. Create new rule: Formatting.
  4. Click on the Conditioning link (labeled None).
    1. The first drop down is the field you want the section to depend on.
    2. The second drop down is the logic statement .
    3. The third drop down is the dependancy for the section.
    4. There can be multiple dependancies and the option can be text or another fields choice. In this option, we chose "is not equal to" to "Ship".
  5. Select Hide this control, meaning when Delivery Method is not equal to Ship the field(s) will remain hidden.

No comments:

Post a Comment