- InfoPath forms have data fields that are defined in a schema.
- Data fields can have rules associated with them (validation, action, etc).
- Rules have conditions and actions (i.e., set a field's value).
In most languages, conditional logic is achieved with something like:
What if you need to set an arbitrary ceiling on a numeric InfoPath field's value without custom code? One relatively simple (albeit somewhat ugly) solution is to use the
string-length()function and basic arithmetic. The following is a screenshot of this scenario from a form I recently designed and developed.
How does it work?
string-length()function returns the length of
FALSE(4 or 5) based on a logical comparison (>, <=, etc). The conditional branches (e.g., the 'if', 'else' blocks) are achieved by subtracting 4 and 5 respectively and multiplying the results.