Skip to content

Set business rules without code, step by step

Say a rule once and Codossier Office keeps it true on every save: refuse a bad date, fill a value from a formula, total the child records. In this guide you write four rules on the billing tables and see where each one lives.

10 steps·7 min read·Customization

Say a rule once; it holds on every save, whatever the door.

What it is

  • Validation rules: a formula that must be true for a record to save, with the message people see when it is not.
  • Computed fields: a formula that fills one field from other fields of the same record.
  • Rollups: a parent field that counts, sums, averages or takes the smallest or largest value of its child records, optionally only the children a filter keeps.
  • Format checks, required and default: set on the field itself, in Builder → Entities.
  • A table's rules are listed in its Business rules part; they are written in the Validation Rules, Computed Fields and Rollup Fields tables of the left panel's Platform group.

Good to know

  • Rules run inside the save. A record that breaks one is never written, whoever sends it: a person, an import, a workflow, Coin or the API.
  • A formula names fields by their schema name and reads only the record being saved. A rule that needs other records, or wants to ask a question, is a plugin script.
  • A unique index over several fields ("one open filing per matter and court") is enforced by the database itself. It has no screen to create it yet (Platform → Entity Multi-Indexes lists the ones that exist): an administrator adds it through the API with the MetadataIndexCreate message, which previews it and refuses it while rows already repeat.
  • The Custom Regex format has no pattern box on the field yet, so as shipped it accepts any text. Use Email Address, Phone Number, URL or GUID, or a validation rule.

Before you start

  • You need administrator rights on the Builder and on the Platform tables (Validation Rules, Computed Fields, Rollup Fields, Relationships).
  • We set four rules on the billing tables: an invoice's due date can never be before its invoice date; a lien's reduction target starts at two thirds of the amount asserted; an invoice's total is the sum of its billable filing costs; and a filing cost must say whether it is billable. Every form below is filled in exactly as you would fill it, up to the marked Save.
  • Rules run inside the save itself. A record that breaks one is never written, whether it comes from a form, an import, a workflow, Coin or the API.

Part 1. Where a table's rules are listed

1Open the table and click Business rules

In Builder → Entities, open a table and click Business rules in its rail. The list holds the table's Validation rules, Computed fields and Rollups, each with what it does. Here, the Jurisdiction Delegate table has validation rules that make sure every delegate names who it is and where it files.

Set business rules without code, step 1: Open the table and click Business rules (The table's rules; The kind of rule; Open one to read it)
1The table's rules2The kind of rule3Open one to read it

2Read a rule: its message, formula, and when it runs

A rule's page shows the Message shown when it fails, the Formula (must be true), when it is Checked on (Create, Update or both) and which fields it is Triggered by. Here: a delegate must name a user or a contact, or the save is refused with that message.

The page is Read-only: rules are written in their own forms, which Part 2 opens.

Set business rules without code, step 2: Read a rule: its message, formula, and when it runs (Read here, written in its form; True means the save goes ahead; On create, update or both; Only when these change)
1Read here, written in its form2True means the save goes ahead3On create, update or both4Only when these change

3Find the rule tables in the left panel

Open the left panel's Full Navigation, then Platform. Its Metadata group lists the rule tables: Computed Fields, Relationships, Rollup Fields, Validation Rules, and Validation Strategies (the formats of Part 4). Or type the name in Search tables above the groups.

Set business rules without code, step 3: Find the rule tables in the left panel (Values from a formula; Needed before a rollup; Totals from child records; Checks before a save)
1Values from a formula2Needed before a rollup3Totals from child records4Checks before a save

Part 2. A validation rule: refuse a bad save

Formulas are written in Power Fx, the spreadsheet-like formula language of Power Apps. A formula names the table's fields by their schema name (due_date, not Due Date): find them in the table's Columns.

4Validation Rules: press New

Click Validation Rules. The list shows every rule in the office, with its table (Entity), message, formula and whether it Is Enabled. Press New.

Set business rules without code, step 4: Validation Rules: press New (A new rule; On or off)
1A new rule2On or off

5The due date cannot be before the invoice date

Fill in the form:

  • Validation Rule Name: Due date on or after the invoice date. Schema Name: a short unique key, invoice_due_after_invoice_date.
  • Formula: what must be true. IsBlank(due_date) Or IsBlank(invoice_date) Or due_date >= invoice_date. The IsBlank parts let a draft without dates through.
  • Error Message: the words people see: The due date cannot be before the invoice date.
  • Trigger Attributes: invoice_date,due_date. The rule runs only when one of them changes; leave it empty to check every save.
  • Is Enabled: on. Entity: Invoice. Apply On: Create,Update (empty means both).

Press Save. A formula that does not parse is refused at once, with the reason.

Set business rules without code, step 5: The due date cannot be before the invoice date (Must be true to save; What people see; Only when these change; Saves the rule)
1Must be true to save2What people see3Only when these change4Saves the rule

Part 3. A computed field and a rollup: fill a value for people

6Computed field: the reduction target fills itself

A computed field writes one field of the same record from a formula, on every save that changes its triggers. Add the field first (here Reduction Target, a decimal on the Lien table), then open Computed Fields and press New:

  • Formula: the value. If(IsBlank(amount_asserted), Blank(), Round(amount_asserted * 2 / 3, 2)): two thirds of the amount asserted, to the cent.
  • Trigger Attributes: amount_asserted. It is recomputed when that changes, so a person can still adjust the target afterwards. A new record is always computed.
  • Computed Field Name, Entity: Lien, Attribute: Reduction Target, the field it writes.

The value is computed before the required check, so a computed field can satisfy a required one.

Set business rules without code, step 6: Computed field: the reduction target fills itself (The value it writes; Recompute when this changes; The field it writes; Saves it)
1The value it writes2Recompute when this changes3The field it writes4Saves it

7Before a rollup: record the link as a relationship

A rollup adds up child records through their lookup to the parent, and it needs that lookup recorded as a relationship first. Open Relationships, press New:

  • Relationship Name and Relationship Schema Name: name it after the child table and its lookup, filing_cost_invoice_id.
  • Child: Filing Cost. Child Lookup Attribute: its lookup to the parent, Invoice. The picker lists fields of every table by name only, so open its search and check you pick Filing Cost's. Parent: Invoice, the table that lookup points to.
  • Extend Visibility: leave it off (on, people who see an invoice also see its filing costs). AI Graph Edge Type: leave it empty.

Press Save. The existing lookup is adopted as it is: nothing new is added to either table. A lookup that is not a single-table lookup to the parent is refused. Keep the relationship once it exists: deleting a relationship deletes its lookup field with it.

Set business rules without code, step 7: Before a rollup: record the link as a relationship (The child's lookup to the parent; The parent table; Saves the relationship)
1The child's lookup to the parent2The parent table3Saves the relationship

8Rollup: an invoice's total is the sum of its billable costs

Open Rollup Fields, press New:

  • Rollup Field Name: what it does, Invoice total from billable filing costs.
  • Aggregate Function: SUM. The others: COUNT (how many children), AVG, MIN, MAX. With no children, a count, sum or average is 0, and a minimum or maximum is empty.
  • Filter Formula (optional): which children count. billable = true keeps only billable costs.
  • Parent: Invoice; Parent Attribute: Total, the field it writes.
  • Child: Filing Cost; Child Attribute: its Amount (leave empty for COUNT); Child Relationship: the relationship from step 7. Here the picker is still empty, because step 7 was not saved for this guide; once it is, the relationship is listed.

Press Save. From then on, every new, changed or deleted filing cost recounts its invoice in the same save. Invoices that already have costs fill in the next time one of their costs is saved.

The attribute pickers list fields from every table by name and date only: two tables can have a field called Amount, so check you picked the child table's.

Set business rules without code, step 8: Rollup: an invoice's total is the sum of its billable costs (SUM, COUNT, AVG, MIN or MAX; Only the children it keeps; The relationship from step 7; Saves the rollup)
1SUM, COUNT, AVG, MIN or MAX2Only the children it keeps3The relationship from step 74Saves the rollup

Part 4. Rules on the field itself: format, required, default

9Format checks: picked when the field is added

A format check holds a field to a pattern on every save, before any rule runs. Pick it in Format when you add the field (Columns → New column):

  • For Single line of text: Email Address, Phone Number, URL, GUID (a record id).
  • For Date and time: Future Only or Past Only (here, a sent date can never be in the future).

The message names the field: Sent On must be a past date/time. An administrator can tighten the email and phone patterns for the whole office in Builder → Settings (email_regex and phone_regex). The field's page does not offer Format afterwards, so choose it here.

Set business rules without code, step 9: Format checks: picked when the field is added (Chosen only when adding; Never in the future)
1Chosen only when adding2Never in the future

10Required and default on an existing field

Open the field from Columns. Here, Filing Cost's Billable.

  • Required: a record cannot be saved without a value. It is checked after computed fields fill theirs, and on every road in, not only on the form.
  • Default value: what a new record starts with when nobody fills it. For a new Yes / No field, the Add field form offers the default as a No / Yes picker; a choice's default is its Default radio.

Switch Required on, then Save on the bar that appears.

Set business rules without code, step 10: Required and default on an existing field (Required; Starting value for new records; Save the change)
1Required2Starting value for new records3Save the change

What next