Skip to content
ProcessIQ

Forms and data

How to show, require and calculate fields from other answers

Use Visible when, Required when and Calculated value to keep forms short and totals correct, with examples you can paste into the form builder.

Last updated

Long forms put people off. Conditional fields show a question only when it applies, make an answer required only when it matters and work out totals for the person. You write the rules in the form builder, using the expression language.

Show a field only when it applies

  1. Open the Form tab and open the field you want to control.
  2. In Visible when, type a rule such as form.leaveType == 'sick'.
  3. Leave it empty to always show the field.

The field appears as soon as the rule becomes true. When it is hidden, it is not required and any answer to it is dropped when the request is submitted.

Require a field only sometimes

Type a rule into Required when. For example, on a "Justification" field, use form.amount > 5000. If the rule is true, the field must be answered. A field that is hidden is never required, even if Required when is true.

Add a calculated value

  1. Add a field and set its Type to Calculated value.
  2. In Calculation, enter an expression such as form.quantity * form.unitPrice.
  3. Place the field after the fields it uses.

The person sees the result update as they type, in a read-only box. When the request is submitted, the server works the value out again and stores that result, so it cannot be edited.

Rules for fields that refer to other fields

  • A rule on a form field can only use other fields of the same form, written form.<key>. Requester details and API call results are not available there.
  • Fields are processed in form order. A calculated field must come after the fields it uses, including other calculated fields. Otherwise it sees an empty value.
  • If any value used in arithmetic is empty or not a number, the result is empty. Make the inputs required where that matters.
  • Avoid dividing by a field that can be zero.
  • A calculated field is not offered as the Limit field on an approval step, which lists only Number and Currency fields. Use a Condition step on the total instead. See approval limits.

Examples

GoalWhereRule
Ask for a doctor's note on long sick leaveVisible whenform.leaveType == 'sick' && form.days > 3
Require a budget code above a thresholdRequired whenform.amount >= 1000
Total with taxCalculationform.net + form.net * 0.075
Show a field for chosen regionsVisible whencontains(form.regions, 'EMEA')
Show a field when a box is tickedVisible whenform.needsLaptop

For the field types themselves, read form fields and validation. To route a request on the same answers, see conditions and branching. The forms and files module page gives an overview.

Try ProcessIQ yourself

Start a free trial or open the shared demo organisation with a test account for every role.