requiredIf, conditional required

Mark a field required only when another field has a specific value.

The requiredIf rule marks a field as required only when an expression returns true. The classic example: a "Reason for refund" field that's only required when the user picked "Refund requested" as the resolution.

The shape

Required only when another field has a specific value

{Resolution} == "Refund"

Required only when the signed-in user is the named approver

{ManagerPerson} == [Me]

Required only above a threshold, and only while unapproved

{Amount} > 1000 and isEmpty({ApprovalCode})

Group membership is not something an expression can ask about. To make a field required for one team only, drive it from a field the form already has (an approver lookup, a department choice), or set required from JavaScript with f365.user.isInGroup(). See the

expression grammar for everything the rule box does and does not accept.

Behaviour

When the expression returns true:

  • The field's label shows the red asterisk
  • An empty value blocks submit, with the message "<Label> is required.". For different wording, put the condition in the field's Custom validation rule instead and set a Custom validation message

When the expression returns false:

  • The field is optional
  • A previously entered value is kept (not cleared, match visibleIf semantics)

Apply on, choosing the form modes

By default a requiredIf rule applies on every form mode. The Apply on checkboxes under the rule box narrow that. Tick only Edit form and the rule is ignored while somebody is still creating the item, so a field can be optional at creation and mandatory once an approver opens it for editing.

Leaving all three ticked means the same thing as not touching them at all, and the published form carries no extra markup in that case. The same three checkboxes already sit under visibleIf and enableIf, with identical semantics.

Related articles