Conditional Rules

A conditional rule watches your Excel data and changes the document as it is generated. Each rule reads as IF something is true, THEN do something.

Typical uses:

  • Skip the document entirely for rows that don't need it — no file, no wasted form count.
  • Tick a checkbox only when a value qualifies.
  • Hide a whole section for customers it doesn't apply to.
  • Lock a field so the recipient can read it but not change it.
  • Fill a value that isn't a straight copy of a column.

Open the rules editor

Rules are configured per file, so the entry point is on the file's own row:

  1. Open your Set of Forms and click Edit Set.
  2. Find the file in the list.
  3. Click the funnel icon on that row.

HTML templates are the exception. They keep their own Conditional Rules panel inside the HTML editor, so they have no funnel icon in the file list. See the HTML Forms guide.


Build a rule

Every rule has a name, an IF side and a THEN side.

IF — conditions

A condition compares a column from your data with a value:

Country      is                United States
Total        is greater than   1000
Notes        is empty

Add as many as you need and join them with and / or.

Both the column and the comparison are chosen from lists rather than typed. That is deliberate: a rule the generator could not understand cannot be saved in the first place, so you never discover a typo after producing three hundred documents.

THEN — actions

Action What it does Available in
Skip document Don't generate this file for that row All types
Set value / Clear value Fill or empty a field All types
Tick / Untick Check or uncheck a checkbox PDF, HTML
Hide / Show Hide a field on a PDF; remove a block in Word, PowerPoint, HTML All types
Lock / Unlock Make a field read-only in the finished document PDF, HTML

The editor only offers actions the selected file can actually perform. If an action you expected is missing, that document type cannot do it — a Word paragraph can be removed and the page reflows, but a PDF has a fixed layout, so a PDF field is hidden in place rather than removed.


How rules run

  • Rules are evaluated once per row, before any field is filled, so a value a rule sets is the value that gets written.
  • Every row is evaluated. A row matching no rule is generated normally.
  • A row whose rule says Skip document produces no file — and is not counted against your monthly form allowance.
  • Rules are per file, never per set. A set containing a PDF and a Word document keeps a separate list for each.

When a rule can't be applied

If a rule cannot be applied to a document — for example it targets a field that no longer exists after the template was replaced — ExForms tells you. The problems are collected across the whole run, listed once each, and shown with your generated documents rather than failing silently.


Formatting a field's value

Separate from rules, an individual mapped field can be given a format, which is applied to its value as the document is generated.

  1. Open the file's field mapping.
  2. Right-click a mapped field in the tree.
  3. Choose Set Field Format.
  4. Enter the format and save.

Use the Excel format codes you already knowdd/mm/yyyy, #,##0.00, 0%. You do not need developer format strings.

A format that would change nothing is rejected when you save it, with an explanation. That is intentional: an unusable format would otherwise pass through untouched, and the only symptom would be output that looks exactly as it did before, with nothing to indicate why.

Formatting is per mapped field, so two fields bound to the same column can be presented differently — for example a full date in the body and just the year in a reference number.


Worked examples

Only produce the form for customers who owe something

IF    Balance    is greater than    0
THEN  (nothing)

…and on a second rule:

IF    Balance    is not greater than    0
THEN  Skip document

Tick the "VAT registered" box when a VAT number is present

IF    VatNumber    is not empty
THEN  Tick    vat_registered

Hide the guarantor block for corporate customers

IF    CustomerType    is    Company
THEN  Hide    GuarantorSection

Lock the totals on the finished PDF

IF    Status    is    Final
THEN  Lock    total_net, total_vat, total_gross

Troubleshooting

The action I want isn't in the list — it isn't supported for that document type. Check the availability column above; PDF cannot reflow, so content-removal actions differ from Word.

My rule didn't fire — check the condition against the actual cell value: trailing spaces and a number stored as text are the usual causes. Comparisons are chosen from a list, so the operator itself cannot be wrong.

A field I hid still appears — confirm you targeted the field name used in the mapping, not the label printed on the form. They are often different.

Nothing was generated for some rows — that is what Skip document does. Check whether a rule matched more rows than you intended.