Open MercatoDocsSearch docsAPI reference

User guide

Creating Rules

Start with one decision you can state in plain language. Choose the rule type, enter its conditions and test with records that should pass and fail.

Step-by-step guide to creating a business rule, configuring fields, conditions, and actions.

Accessing the Rules Page

  1. Navigate to Business Rules > Rules
  2. Click Create Rule
  3. Fill out the form sections

ℹ️ Requires business_rules.rules.create feature permission.

Create Rule Form Create Rule Form

Form Fields

FieldRequiredFormatDescription
Rule IDUppercase, _, max 50 charsUnique identifier, auto-generated from name. Cannot change after creation.
Rule NameText, max 200 charsHuman-readable name. Use clear, descriptive names (e.g., "Block Work Order Release Without Materials").
DescriptionText, max 5000 charsBusiness rationale, special cases, policy references, dependencies.
Rule TypeSelectGUARD (block/allow), VALIDATION (validate data), CALCULATION (compute values), ACTION (side effects), ASSIGNMENT (auto-populate). See Rule Types.
Rule CategoryText, max 50 charsLogical grouping (e.g., "Material Planning", "Quality Control", "Approval Workflow").
Entity TypeCombobox, max 50 charsEntity to apply rule to (WorkOrder, Order, Invoice, Customer, Product, User, Task, Ticket, Deal, Contact). Case-sensitive.
Event TypeCombobox, max 50 charsLifecycle event trigger (beforeCreate/Update/Delete/Save, afterCreate/Update/Delete/Save, onStatusChange, onAssign). Leave empty for any event.

Metadata

FieldDefaultRangeDescription
Priority1000-9999Execution order (higher first). GUARD: 500-1000, VALIDATION: 300-500, CALCULATION: 200-300, ACTION: 50-200, ASSIGNMENT: 0-100.
EnabledBooleanActive/inactive. Only enabled rules execute.
Version1Integer ≥1Audit trail. Increment for significant changes.
Effective FromDateRule becomes active. Leave empty for immediate activation.
Effective ToDateRule becomes inactive. Leave empty for indefinite.

Effective Date Use Cases:

Conditions

Define when the rule applies. See Conditions Guide for details.

Key Points:

Actions

Configure success (conditions true) and failure (conditions false) actions. See Actions Guide for details.

Key Points:

Saving & Validation

Save:

  1. Click Create Rule
  2. Rule immediately available (if enabled)
  3. Redirect to detail page

Validation Errors:

Testing

  1. Manual: Execute API with dryRun: true
  2. Natural: Trigger event (e.g., update entity)
  3. Logs: Business Rules > Execution Logs
  4. Review: Verify conditions and actions

Example: Block Work Order Release Without Materials

Basic Information:

Metadata:

Conditions:

AND:
  - newStatus = "RELEASED"
  - materialsAvailable = false

Failure Actions (execute when conditions true = block):

Success Actions: None (allow transition)

Next Steps

Previous: Condition Builder · Next: Execution Logs