Skip to main content

Creating Rules

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 ID✅Uppercase, _, max 50 charsUnique identifier, auto-generated from name. Cannot change after creation.
Rule Name✅Text, 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 Type✅SelectGUARD (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 Type✅Combobox, 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.
Enabled✅BooleanActive/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:

  • Schedule future activation (new policy)
  • Temporary promotions/pilots
  • Coordinate with system updates

Conditions​

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

Key Points:

  • No conditions = always execute (match all)
  • Dot notation for fields (user.email, address.city)
  • 15 operators (=, !=, >, <, IN, CONTAINS, STARTS_WITH, MATCHES, IS_EMPTY, etc.)
  • AND/OR groups, nest up to 10 levels

Actions​

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

Key Points:

  • Success: conditions true → execute
  • Failure: conditions false → execute (GUARD uses failure to block)
  • Sequential execution, message interpolation ({{field}})
  • 10 action types (ALLOW/BLOCK_TRANSITION, LOG, SHOW_ERROR/WARNING/INFO, NOTIFY, SET_FIELD, CALL_WEBHOOK, EMIT_EVENT)

Saving & Validation​

Save:

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

Validation Errors:

  • Error messages appear next to fields
  • Scroll up to see all errors
  • Fix and retry

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:

  • Rule ID: BLOCK_WO_RELEASE_WITHOUT_MATERIALS
  • Rule Name: "Block Work Order Release Without Materials"
  • Description: "Prevents releasing work orders to production when required materials are not available in inventory"
  • Rule Type: GUARD
  • Rule Category: "Material Planning"
  • Entity Type: WorkOrder
  • Event Type: onStatusChange

Metadata:

  • Priority: 800
  • Enabled: Yes
  • Version: 1

Conditions:

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

Failure Actions (execute when conditions true = block):

  • BLOCK_TRANSITION
  • SHOW_ERROR: "Cannot release work order. Required materials are not available in inventory. Please check material availability and try again."
  • NOTIFY: Material planner

Success Actions: None (allow transition)

Next Steps​