Documentation
Getting Started
Data Grid
Modeling
Approvals
Users, Roles & Security
Administration
Integration & API
Installation
Migrating from MDS
Architecture
Documentation/Business Rules/Creating a Rule from Templates

Creating a Rule from Templates

A template is a guided starting point. Pick one, fill in the form, and Primentra builds the rule. Every template produces the same rule structure — the template only sets which columns are offered and what the builder starts out as.

Open the gallery: Settings → Manage Models → [Entity] → Business Rules → Gallery. From the Rules tab, Add rule takes you there too.

The template gallery, showing a card for each rule template with its name and a one-line description
The template gallery, showing a card for each rule template with its name and a one-line description(click to enlarge)

The nine templates

TemplateBuilds
Unique valueNo two rows may share the same value in one column.
Combination uniqueTwo or more columns must be unique together, not on their own.
Number limitsRanges and limits on a number, combined with AND / OR to any depth.
Text formatFormat, length and allowed values.
Date limitsBefore, after, between — against a fixed date, today, or another column.
Required when…A value must be present, but only when something else holds.
Compare two columnsOne column measured against another in the same row.
Custom ruleBuild both halves yourself — any column, any combination.
Fill a valueFill a column when it is left empty. The only template that writes.

Number limits, Text format and Date limits restrict the column picker to columns of that data type. The other six offer every column except the system date columns.

Building a rule

  1. Select a template. The Editor tab opens with the guided form.
  2. Type a Rule name. Stewards see this next to a flagged row, so name it after the requirement. The name must be unique within the entity.
  3. Pick the Column, or the columns for a combination key.
  4. Add the checks under [Column] must satisfy.
  5. Optionally add a condition under Only when. Without one, the rule applies to every row.
  6. Choose what happens If a row breaks this ruleWarn and flag or Refuse the save.
  7. Optionally type a Message shown to the user. Leave it empty to use the generated sentence.
  8. Click Test rule in the right panel, then Save rule.

The panel on the right shows the rule as a sentence while you build it, under This rule reads, along with where it runs and how it treats empty values.

Unique and Combination unique

Tick the columns that must be unique. Tick one for a single-column rule, several for a combination key. Two empty values never collide — a blank is not a duplicate.

Watch it done in 4:57 — a Unique value rule stops two rows sharing one value, tested against duplicates, capitals and empty cells:

Keep a column unique with a business rule in Primentra

Watch it done in 4:53 — a Combination unique rule over two columns refuses a duplicate pair, with no single cell at fault:

Make a combination of columns unique in Primentra

Text format

The matches the format check takes a mask rather than a regular expression:

CharacterMatches
AA letter
9A digit
*A letter or a digit

Anything else in the mask matches itself. The form shows the LIKE pattern the mask compiles to.

Watch it done in 5:41 — a Text format rule accepts only the agreed store formats, and a refused save is shown to a steward:

Text format rules — patterns, length, allowed values in Primentra
The rule editor with a Text format rule open, showing the mask AAA-9999 and the LIKE pattern it compiles to
The rule editor with a Text format rule open, showing the mask AAA-9999 and the LIKE pattern it compiles to(click to enlarge)

A mask compiles to LIKE, so the database enforces it on every write path.

A regular expression does not. The matches a regular expression check is evaluated in the browser and on the API only. SQL Server has no regular expression engine, so this one cannot be enforced during an import or a staging batch. Use a mask where you can.

Required when…

This template asserts that a column has a value, and it needs a condition. Without one it only repeats the attribute's own Required flag, which is cheaper and shows in the grid immediately. The form says so, and the save is refused until you add a condition or set the flag instead.

Watch it done in 5:22 — a column becomes required only when a store has fifty or more employees, in its three states:

Conditional required fields with business rules in Primentra

Fill a value

The one template that writes. It fills a column on rows that left it empty.

Watch it done in 4:51 — a rule fills a column when it is empty, always or only under a condition, and never overwrites a value, not even zero:

Fill a value automatically with a business rule in Primentra
  1. Pick the Column to fill. Code and Name are not offered — a code comes from Auto-generate Code, and Name identifies the row.
  2. Type the Value to fill it with. For a domain column, type the code of the row to point at.
  3. Optionally add a condition under Only when.
  4. Save.

There is no severity to choose: the rule cannot refuse anything.

What you wantHow to build it
Every new record starts as ActiveFill Status with *Active*, no condition
External suppliers get a 12-month reviewFill ReviewCycle with *12*, only when Type is *External*
Site and cost centre both derivedFill Site with *Zurich*, then fill CostCentre with *CH-100* only when Site is *Zurich*
A filling rule never overwrites. Correcting a value a rule supplied is safe — type over it and the rule leaves it alone from then on, because the column is no longer empty.

Managing rules

On the Rules tab, each rule shows its name, severity badge and template. Filter the list with All, Active or Inactive.

  • Disable / Enable switches a rule off and on without deleting it.
  • The arrows on the left move a rule up or down. Order decides which filling rule runs first.
  • The pencil opens the rule for editing.
  • The bin deletes it. Deleting a rule also removes the stored failure records for it.

Ready to get started?

Start managing your master data with Primentra today.

View Pricing
Creating a Rule from Templates | Business Rules | Docs | Primentra