Skip to content

Logic & calculations

One small expression language is used for Show only when rules, computed fields and computed conditions. It is deliberately simple and safe: no code runs, only these operators and functions.

Values

Answers are referred to by their tag name: salary, has_bonus, start_date. Inside a repeating group, the item's own fields come first, then top-level answers. Literals: numbers 12, 0.2; text "flat"; true, false, null; lists ["CA", "NY"].

Operators

OperatorsNotes
+ - * / %Arithmetic. + adds when both sides are numbers and joins text when either side is text; use concat(a, b) to be explicit.
== != < <= > >=Comparison. Numbers typed as text compare as numbers.
and or not (also && || !)Logic. Empty text, 0, false, null and empty lists count as false.
x in ["a", "b"]Membership.
items.rateThe list of one field across a repeating group.

Functions

FunctionExample → result
upper, lower, title, trimtitle("jane doe") → Jane Doe
concat(a, b, …)concat(first_name, " ", last_name)
len(x), count(list)count(attorneys) → 3
join(list, sep)join(parties.name, "; ")
sum(list), sum(list, "field")sum(items.amount)
min, max, round(x, d), floor, ceil, absround(total * 1.2, 2)
if(cond, a, b)if(count(attorneys) > 1, "attorneys", "attorney")
coalesce(a, b, …)First non-empty value
contains(list, x), empty(x)contains(states, "CA")
plural(n, "day"), plural(n, "party", "parties")plural(term_years, "year") → years
words(n)words(1250) → one thousand two hundred and fifty
format_number(x, decimals), format_money(x, "EUR")format_money(sum(items.amount), "USD") → $12,500.00
today()Today's date
format_date(d, "long")Styles: long, medium, short, full, iso
add_days, add_months, add_yearsadd_days(signed_on, 30)
days_between(a, b), years_between(a, b), year(d)years_between(dob, today()) → age
number(x), string(x)Conversions

Computed fields

Add a computed field in the designer (Pro), give it a tag name and an expression, and choose how it is shown in the document: text, number, money, date or yes/no. Use its tag in the Word document like any other: {total_fee}. Computed fields can use other computed fields; circular references are reported.

Examples

total_fee          sum(attorneys.rate) * estimated_hours
term_end           add_years(effective_date, term_years)
salary_in_words    words(salary) + " dollars"
notice_period      if(years_of_service > 5, "three months", "one month")
parties_list       join(parties.name, ", ")

Computed conditions

A section can be controlled by an expression instead of a checkbox. Select the yes/no question created for the section, change its type to Computed, and enter for example salary > 100000 and is_executive. The section renders when the expression is true.

Errors

Mistyped expressions are flagged in the designer with the position of the problem. At interview time, an expression that cannot be evaluated shows an error under its field and renders blank; it never blocks generation.