Sunday, October 28, 2007

Hide/Display Debug Fields for InfoPath 2003

I have been working on a InfoPath 2003 project for about one month. I have put some hidden fields on the form for debug or values which are used by some Rules but not for display purpose. At the beginning, I thought to use other visible fields as condition for their display condition since fields/controls do not have hidden property I can set directly. For example, I set those hidden fields' conditional format as hidden if other visible controls is present.

However, when I want to set those fields visible for debug purpose, it is very tedious to go to each control to enable their visibility, specially when there are many hidden fields. What I need is a quick way to set their visibility by one flag.

Finally, I found a way to do that. There is place I can set Rules for Form Open, that is the place I can set a variable or field to true or false. I named this field as SetHiddenFieldVisible as boolean. All the hidden fields/controls conditional format is changed to hidden if this var is false, or 1 = 2. This makes my debug much easier. By using this, I found several bugs. For example, some hidden fields were set as invalid values (string to a boolean value). Because they are hidden fields, I could not see the error when I got an error message. When I turn on the visible flag, I could see these fields marked as red right away.

By set some initial values when the Form is opened, I could set many initial values used later on in the form. This simplifies my Rules and Conditional Format settings, and it is easy to update.