Skip to content

Required for save rule – refuse the save while a field is empty

A required for save rule makes a field mandatory – always or only under a condition. A record whose required field is empty cannot be saved. This page describes its settings and behaviour. It is intended for administrators who configure business rules.


1. At a glance

Purpose Refuses the save while a field is empty and the condition of the rule is true
Typical use Mandatory fields; fields that are only mandatory in a certain status ("Reason" when a ticket is rejected)
Related Expression validation rule (checks a value that is there)

2. Settings

Setting Meaning Default / required
"Field" The field that must not be empty required
"Condition" A condition (an expression with the result true or false). The field is required only while it is true. required
"Disabled" The rule does not apply off

Plus "Display Name", "Description" and "Tags" (see Business rules).

The condition carries the rule. A rule without a condition is skipped – it makes nothing mandatory. For a field that is always required, use a condition that is always true.


3. Behaviour

When the field is checked

  • At every save. If the condition is true and the field is empty, the save is refused. Nothing is written, and the user sees "Error occurred while saving" with "Field(s) … must be filled in for …", followed by the entity and the id of the record.
  • While the form is open, an input field whose field is required and still empty is highlighted in the warning colour of the theme. The input block setting "No Required Marking" switches the highlighting off for that block. A field that a set before save rule fills is not highlighted – the rule fills it during the save.
  • Through the REST API, a refused save returns the list of the missing fields.

The check runs after the Before Save UI actions – they can still fill the field. A field that an active set before save rule fills is checked only after that rule ran, so the value the rule writes satisfies the requirement (see Business rules, section 3). If the rule leaves the field empty, the save is refused like for any other empty required field.

What counts as empty

  • A field without a value or with an empty text.
  • A reference to a record that is "all zeros" (no record selected).
  • A date or date/time of 1 January 1753 or earlier. nexxcite stores an empty date as 1 January 1753, the earliest date the database knows. Every later date is a value – a required birth date of 12 May 1985 is filled in.

A text that consists of blanks, the number 0 and the value "false" are not empty.

  • Several rules for the same field: the field is required as soon as the condition of one of them is true.
  • Related records that are saved together with the record are checked as well. This can be switched off per relationship with "Check Required Fields" in the relationship editor.

Errors

The condition must return true for the field to be required. A condition that returns anything else – false, an empty value, a text – leaves the field optional. A condition whose expression no longer exists is skipped and written to the application log.


4. Examples

Always required. Entity Customer, "Field" = Name, "Condition" = the constant true.

Required in a status. Entity Ticket, "Field" = Rejection reason, "Condition" = Status equals Rejected. A ticket with the status "Open" can be saved without a reason; as soon as the status is "Rejected", the save is refused until a reason is entered.


5. Limitations

  • The rule only checks for emptiness. Whether a value is acceptable is decided by the validation rules.
  • A required field that a set before save rule fills is checked late in the save. If the rule leaves it empty, the record itself is not written, but related records that are saved together with it and attached files have already been stored at that point.
  • A record that is already open keeps the rules it read when it was opened; changed rules apply after reopening it.