Qdabra FormsDesigner - User Manual Building form logic with rules All manuals

Chapter 2 - Conditions

A condition decides whether a rule acts. Action rules use it as an on/off switch, formatting rules apply their formatting while it is true, and validation rules flag the field while it is true. This chapter covers the Condition editor, which is the same for all three kinds of rules.

2.1 Opening the Condition editor

In the Rule Details panel, click the Condition line. For a new rule it reads "None - Rule runs when field changes".

The Condition editor as it opens for a new rule: one row, ready to be filled in.

The editor has four areas:

Area Purpose
Rows Each row is one comparison: field / operator / value.
Row buttons (right side) + adds a row after this one. The tree icon converts the row into a nested AND/OR group. The trash can deletes the row. The last two are disabled while there is only one row.
Condition text The strip under the rows shows the whole condition written out as an expression, updated as you edit. It is exact rather than easy to read, so use it to confirm the logic before you click OK.
Footer Delete removes the condition completely (back to "None"). OK saves. Cancel discards your edits. Undo and Redo are in the header.

2.2 Building one comparison

The field

The first dropdown offers:

What the first entries are depends on what owns the rule. For a rule on a field, the starting point is that field, so its siblings are listed. For a rule on a control such as a text box (formatting rules, Chapter 5), the starting point is the parent group of the bound field, so the dropdown shows the group name first; for a rule on a section or repeating table it is the bound group itself; for a button or form-load rule it is the form's root group. Whatever the starting point, Select a field or group... reaches every field, so use it whenever the field you want is not listed. If you are unsure what a condition refers to, switch the row to The expression and read the XPath: . is the starting point described here.

The operator

Group Operators
Compare = , ≠ , < , ≤ , > , ≥
Presence is present, is not present
Emptiness is blank, is not blank
Text contains, does not contain, begins with, does not begin with
Pattern matches pattern, does not match pattern

is blank means the field exists but has no value. is not present means the node does not exist at all, which matters for optional elements and repeating rows. For everyday "the user typed something" checks, use is blank / is not blank.

When the operator does not need a value (the presence and emptiness groups), the value box is disabled.

Operator set to "is not blank". The value box is greyed out because no value is needed.

The value

The third dropdown decides what the field is compared with:

Choice What happens
Type text... A text box appears. Type the literal text. The condition text shows it in quotes, for example "@".
Type number... Same, for a numeric literal. Only offered for numeric comparisons.
Select a field or group... Compare with another field. Opens the Data Fields picker.
Use a formula... Opens the Formula editor (see Chapter 3, section 3.3) so you can compare with a calculated value such as today().

The list adapts to the operator. For example contains only offers Type text... and Use a formula....

2.3 Combining rows with AND / OR

Click + on a row to add another row after it. A vertical bar with a toggle appears on the left. The toggle reads AND (green) or OR (orange); click it to switch. One toggle applies to every row in that group, so you cannot mix AND and OR at the same level without a nested group.

Two rows joined by AND. The condition text reads "Name is not blank AND Name = ...".

The toggle switched to OR, and the second row compares EmailAddress with the text "@".

2.4 Nested groups

To express something like A or (B and C), convert a row into a group:

  1. Click the tree icon on the row that should start the inner group.
  2. The row moves into a box with its own AND/OR toggle, and an empty row is added inside the group.
  3. Fill in the inner rows and set the inner toggle.

Row 2 converted into a group. The inner toggle is AND, the outer is OR, and the condition text shows the parentheses.

The condition text under the rows shows the exact logic, parentheses included. It takes a moment to read, but it is the only place that shows precisely what will be saved, so check it before you click OK.

2.5 Writing the condition as an expression

Choose The expression in the field dropdown when the visual builder cannot say what you need, for example a count() over a repeating table or a comparison against a value in a secondary data source with a filter. The row collapses to one text box that holds an XPath boolean expression. Click it to open the editor.

A row in expression mode. The whole comparison is a single XPath box.

Rules of thumb for expressions:

2.6 What the saved condition looks like

After OK, the Condition line in Rule Details shows the condition in readable form, in green.

Rule Details after saving. The Condition line reads "Name is not blank".

To change it, click the line again. To remove it, open the editor and click Delete.

2.7 Common patterns

Goal Condition
Field has a value Field is not blank
Field equals a fixed choice Status = Type text... Approved
Text contains a marker EmailAddress contains Type text... @
Date is in the past DueDate < Use a formula... today()
Either of two flags A = true OR B = true
Required only when another field is set Comment is blank AND NeedsComment = true (as a validation rule on Comment)
Row count check on a repeating table The expression: count(../my:Items/my:Item) = 0

2.8 Summary

Next: Chapter 3 - Action Rules.

© Qdabra Software  |  Questions and corrections: [email protected]  |  Preview copy, not linked from the public site.