How to fix problems with conditional formatting

My rule to hide or format a control based on the value of a field is not working. What can I do?

Sometimes a conditional formatting rule that works in InfoPath doesn't work on a device, or requires a screen refresh to work. This is often because the device does not execute logic and screen refreshes exactly the same way as InfoPath does on a PC. Here are two ways to make your conditional formatting form design more robust on devices:

1. Include a control bound to the trigger field in the view where the formatting occurs.

This is the most common solution to a conditional formatting problem. If your formatting rule is conditioned on the value of Field1, then Field1 needs to 'exist' as a control in the view where the formatting rule is executed. Specifically:

The control bound to Field1 should be a textbox or checkbox, not a calculated value control.

The control must not be hidden using a rule, nor in a section hidden by a rule.

But what if you don't want the user to see the control in the view? The trck is that while the control can't be hidden with a rule it can certainly be 'camouflaged' so users won't see it. Here are two ways to camouflage your control:

A checkbox control can be formatted to a vanishingly small size, such as 1 pixel. This may work better on some platforms than others.

A textbox control can be formatted to have no border, no fill, and an 8-point font that's the same as the background color (e.g. white text on white background). This works on all platforms and is especially effective when the control is located in some empty place in the form that's unlikely to be touched.

Tip: Be careful not to forget the invisible control exists and accidentally delete it.

In general setting a field values using a rules will be more robust than using default values. This is especially true when one default value is derived from other default values.

Example 1: You have a formatting rule conditioned on the value of Field1. The default value of Field1 is defined to equal Field2+Field3, whose values are set by rules on a button. This may not work on the device. Instead, put another rule on the button that explicitly sets the value of Field1.

Example 2: You have a formatting rule conditioned on the value of Field1. The default value of Field1 is defined using functions such as concat() and today(). This may not work on the device. Instead, if possible, create a rule on form load that explicitly sets the value of Field1 using the same logic.