Friday, January 22, 2010

Clearing an Option Button in InfoPath

While this is basically a SharePoint blog, I use InfoPath a lot paired with SharePoint. They are pretty amazing together. An InfoPath form template saved to a SharePoint document library can store important data that can be displayed in a report-like fashion, manipulated into views, used to fire workflows, and much more. Additionally, the fact that Microsoft made the licensing all-encompassing for the Office Suite and gave InfoPath browser compatibility ensures that it will be an integral part of the workplace for decades to come. It is a great tool for gathering information from your organization.

However, although InfoPath is a great program, it is not intuitive. In fact, sometimes it is downright annoying. (Although I am sure the same can be said for SharePoint at times, right?)

I was working with a existing form that I needed to modify and I wanted to add some conditional formatting to make certain sections display when the option button selected was "Yes" and to disappear from view when the option button selected was "No." The challenge I ran into was that I could make the section disappear when "No" was selected, but if the user had inadvertently clicked on an option button in the section being hidden, that field stayed populated, hidden or not. Because this information was being sent to a database in addition to being published on SharePoint, I needed to clear the option buttons on the sections being hidden.

Here is the scenario:

OptionButton1 - Yes = True, No = False, No value is set as a default selection
OptionButton2 - Yes = True, No = False, No value is set as a default selection
However, OptionButton2 should be NULL if OptionButton1 is set to False (No)

So I created a rule to change the value of OptionButton2 based on a False value for OptionButton1.

OptionButton Properties --> Rules --> Add
Condition - OptionButton1 = False
Action - Set a Field's value
Field - OptionButton2
Value - ?????

Here is where I hit the snag. The value choices for OptionButton2 only had the following: (blank), TRUE, FALSE, 1 or 0. Choosing (blank) did not work and I didn't want the other options, since I wanted no value whatsoever.



















It was a puzzle. The fix? Leaving the "Value" field completely blank. Obvious, you say? Well, it wasn't to me. But it worked like a charm!



1 comment:

  1. Thank you for that helpful article! Greets from Germany
    Sven

    ReplyDelete