Add a validation rule or computed field
A validation rule is a condition every record of an entity must meet, checked by every record write; a computed field is a field whose value is calculated. Both are designed on the entity's page in the Metadata Designer and belong to whoever owns the entity.
Prerequisite
metadata.writeat the scope you design in — the platform for a platform entity, the tenant for its own.- The entity and its fields; for a computed field, the field that will hold the value (add it under Fields first).
Steps
- Open Metadata Designer and select the entity.
- Under Rules, give a key and a name, choose the field, the test (is, is not, is one of) and the value a record must meet, what happens when it does not (error, warning or info) and the message the person sees, and press Add rule.
- Under Computed fields, choose the field that holds the value, the calculation (join text, add, subtract, multiply, divide, or count or sum over a relation) and its parts, and the mode (virtual or materialized), and press Save computed field.
Result
Every record write — creating or editing in Explorer, a form, an action that sets fields, a workflow's validation step — checks the rule before anything is written, and a refusal names the rule. A platform entity's rules apply in every tenant that reads it. A package that carries the entity carries its rules and computed fields.
Keep in mind One condition per rule for now; add another rule for another condition. Explorer's record view does not show computed values yet, and a materialized computed field is not yet recomputed automatically when the fields it reads change.
Tip A computed field cannot read its own value, and a chain of computed fields that loops or runs too deep is refused with the reason.
