Custom Validation Messages for Business Rules

Introduction

Standard validation in Business Central provides generic error messages that often lack context about specific business rule violations. Users see messages like "You cannot delete this record" or "The value is not valid" without understanding what rule was violated, why the rule exists, or how to correct the issue.

Effective validation messages should explain what rule was violated, why the rule is important, what impact the violation would have, and specifically how to correct the issue. Poor messaging leads to user frustration, repeated errors, support tickets, and workarounds that bypass business rules.

QUALIA Rule Engine's Message actions enable custom validation messages that provide contextual information, explain business rules clearly, suggest corrective actions, and include dynamic data from current records. Messages can be informational (warnings that allow continuation), blocking (errors that prevent operation), or conditional (shown only when specific conditions met).

Message action capabilities:

  • Custom error messages that block operations

  • Warning messages that inform but allow continuation

  • Dynamic message content with field value substitution

  • Conditional message display based on rules

  • Multi-line formatted messages with structured information

  • Messages with corrective action guidance

Part 1: Basic Validation Messages

Simple Blocking Message

Basic validation message that prevents operation from completing demonstrates core message action structure.

Validation Set: Customer - Delete Validation - OnDelete

Rule 1: Prevent Deletion with Open Balance

Table: Customer (18)

Condition:

[18:62]

Action - Message:

Type: Error (blocks operation)

Message:
Cannot delete customer with outstanding balance.

Customer: [18:2]
Current Balance: $[18:62]

Placeholders Used in This Example:

  • [18:62] - Customer (Table 18): Balance (LCY) (Field 62) - Current account balance

  • [18:2] - Customer (Table 18): Name (Field 2) - Customer name displayed in message

  • Condition check: [18:62] <> 0 - Validates balance is non-zero

  • Message type: Error - Blocks the delete operation from completing

Result: Deletion blocked with clear explanation of constraint.

Warning Message (Non-Blocking)

Rule 2: Warn About Inactive Customer

Validation Set: Sales Order - Customer Status Check - OnInsert

Condition:

[Customer:CustomLastOrderDate] < [T]

Action - Message:

Type: Warning (allows continuation)

Message:
INACTIVE CUSTOMER

Customer: [Customer:2]
Last Order Date: [Customer:CustomLastOrderDate]
Days Since Last Order: [T - [Customer:CustomLastOrderDate]

Result: User warned but can proceed with order creation.

Part 2: Messages with Context

Including Field Values

Messages incorporating field values provide specific context about rule violations.

Validation Set: Sales Order - Credit Limit Validation - OnRelease

Rule 1: Block Credit Limit Violation

Source References:

1. Customer (18)
   Link via: [36:2] = [18:1]

2. Customer Ledger Entry (21)
   Link via: [18:1] = [21:3]
   Reference Filters:
     [21:13]

Condition:

SUM(21:14) + [36:109] > [18:59]

Action - Message:

Type: Error

Message:
ORDER EXCEEDS CREDIT LIMIT

Customer: [18:2]
Customer No.: [18:1]

Credit Limit: $[18:59]
Current Balance: $[SUM(21:14)]
This Order: $[36:109]
Total Exposure: $[SUM(21:14) + [36:109]]
Amount Over Limit: $[SUM(21:14) + [36:109] - [18:59]

Placeholders Used in This Example:

  • [36:2] - Sales Header (Table 36): Sell-to Customer No. (Field 2) - Links order to customer

  • [18:1] - Customer (Table 18): No. (Field 1) - Customer number for linking and display

  • [18:2] - Customer (Table 18): Name (Field 2) - Customer name in message

  • [21:3] - Customer Ledger Entry (Table 21): Customer No. (Field 3) - Links ledger entries to customer

  • [21:13] - Customer Ledger Entry (Table 21): Open (Field 13) - Filter for open entries (false = not yet paid)

  • [21:14] - Customer Ledger Entry (Table 21): Remaining Amount (Field 14) - Outstanding balance on entry

  • SUM(21:14) - Aggregate function: Total of all open ledger entry amounts (current balance)

  • [36:109] - Sales Header (Table 36): Amount Including VAT (Field 109) - Current order amount

  • [18:59] - Customer (Table 18): Credit Limit (LCY) (Field 59) - Customer's credit limit

  • SUM(21:14) + [36:109] - Calculated expression: Total exposure (existing balance + new order)

  • SUM(21:14) + [36:109] - [18:59] - Calculated expression: Amount over limit

  • Condition: SUM(21:14) + [36:109] > [18:59] - Checks if total exposure exceeds credit limit

  • Source Reference filtering: Filter [21:13] is false configured in linked table setup

Result: User receives detailed credit analysis and clear corrective actions.

Calculated Values in Messages

Rule 2: Inventory Shortage Details

Validation Set: Sales Line - Inventory Check - OnValidate

Source References:

1. Item (27)
   Link via: [37:6] = [27:1]

2. Sales Line (37) - Other open orders
   Link via: [27:1] = [37:6]
   Reference Filters:
     [37:3] <> [Current:3]  // Other orders
     [37:120]

Condition:

[37:15] > [27:Inventory]

Action - Message:

Type: Error

Message:
INSUFFICIENT AVAILABLE INVENTORY

Item: [27:1] - [27:3]
Requested Quantity: [37:15]
Current Inventory: [27:Inventory]
Committed to Other Orders: [SUM(37:15)]
Available Quantity: [27:Inventory - SUM(37:15)]
Shortage: [37:15 - ([27:Inventory - SUM(37:15)])]

Outstanding Purchase Orders: [27:CustomPOQuantity]
Next Expected Receipt: [27:CustomNextReceiptDate]

Options:
1. Reduce order quantity to [27:Inventory - SUM(37:15)]

Placeholders Used in This Example:

  • [37:6] - Sales Line (Table 37): No. (Field 6) - Item number on line, for linking

  • [27:1] - Item (Table 27): No. (Field 1) - Item number for linking and display

  • [27:3] - Item (Table 27): Description (Field 3) - Item description in message

  • [37:15] - Sales Line (Table 37): Quantity (Field 15) - Requested quantity

  • [27:Inventory] - Item (Table 27): Inventory field - Current on-hand inventory

  • Source Reference: Other Sales Lines linked via [27:1] = [37:6]

  • [37:3] - Sales Line (Table 37): Document No. (Field 3) - Filter to exclude current order

  • [Current:3] - System placeholder: Current record's Document No. - Used to filter out current line

  • [37:120] - Sales Line (Table 37): Status field (Field 120) - Filter for 'Open' orders

  • SUM(37:15) - Aggregate function: Total quantity committed to other open orders

  • [27:Inventory - SUM(37:15)] - Calculated expression: Available quantity after other commitments

  • [37:15 - ([27:Inventory - SUM(37:15)])] - Calculated expression: Shortage amount

  • [27:CustomPOQuantity] - Item (Table 27): Custom PO Quantity field - Outstanding purchase orders

  • [27:CustomNextReceiptDate] - Item (Table 27): Custom Next Receipt Date field - Expected delivery date

  • Condition: [37:15] > [27:Inventory] - SUM(37:15) - Checks if requested quantity exceeds available

  • Source Reference filtering: Filters [37:3] <> [Current:3] and [37:120] is 'Open' configured in linked table setup

Result: User understands exact inventory situation and available options.

Part 3: Conditional Messages

Messages Based on Multiple Conditions

Messages can include conditional content that adapts based on data conditions.

Validation Set: Item - Price Validation - OnModify

Rule 1: Validate Price Changes

Table: Item (27)

Scenario:

Scenario 1: {27:27} is <>[27:27]

Condition:

Condition 1: [27:27] is <{27:27} * 0.8
// Price decreased by more than 20%

Condition 2: [27:27]

Action - Message:

Type: Warning

Message:
SIGNIFICANT PRICE CHANGE DETECTED

Item: [27:1] - [27:3]
Previous Price: ${27:27}
New Price: $[27:27]
Change: $[27:27 - {27:27}]
Percentage: [[27:27 / {27:27} - 1] * 100]%

[IF([27:27] < {27:27}, 'PRICE DECREASE', 'PRICE INCREASE')]

Current Cost: $[27:22]
[IF([27:27] < [27:22], 
  'WARNING: New price is below cost. Margin will be negative.',
  'New Margin: ' + [([27:27] - [27:22]) / [27:27] * 100] + '%'
)]

[IF([27:27]

Placeholders Used in This Example:

  • {27:27} - Item (Table 27): Unit Price (Field 27) - OLD value before modification (curly braces)

  • [27:27] - Item (Table 27): Unit Price (Field 27) - NEW current value (square brackets)

  • [27:1] - Item (Table 27): No. (Field 1) - Item number in message

  • [27:3] - Item (Table 27): Description (Field 3) - Item description in message

  • [27:22] - Item (Table 27): Unit Cost (LCY) (Field 22) - Item cost for margin calculation

  • Old value comparison: {27:27} is <>[27:27] - Scenario checks if price changed

  • Decrease threshold: [27:27] is <{27:27} * 0.8 - Condition checks if decreased by more than 20%

  • Increase threshold: [27:27] is >{27:27} * 1.5 - Condition checks if increased by more than 50%

  • Change amount: [27:27 - {27:27}] - Calculated difference between new and old price

  • Percentage change: [[27:27 / {27:27} - 1] * 100] - Calculated percentage change

  • Conditional direction: IF([27:27] < {27:27}, 'PRICE DECREASE', 'PRICE INCREASE') - Dynamic label based on direction

  • Below cost check: IF([27:27] < [27:22], 'WARNING...', 'New Margin...') - Conditional warning if price below cost

  • Margin calculation: [([27:27] - [27:22]) / [27:27] * 100] - New profit margin percentage

  • Impact message: IF([27:27] < {27:27}, 'Price reductions...', 'Significant increases...') - Context-specific guidance

  • Note: Old value placeholders {27:27} only available on Modify triggers

Result: Message adapts to show relevant warnings based on increase vs. decrease.

  • Change amount: [27:27 - {27:27}] - Calculated difference between new and old price

  • Percentage change: [27:27 / {27:27} - 1] * 100 - Calculated percentage change

  • Conditional direction: IF([27:27] < {27:27}, 'PRICE DECREASE', 'PRICE INCREASE') - Dynamic label based on direction

  • Below cost check: IF([27:27] < [27:22], 'WARNING...', 'New Margin...') - Conditional warning if price below cost

  • Margin calculation: ([27:27] - [27:22]) / [27:27] * 100 - New profit margin percentage

  • Impact message: IF([27:27] < {27:27}, 'Price reductions...', 'Significant increases...') - Context-specific guidance

  • Note: Old value placeholders {27:27} only available on Modify triggers

Result: Message adapts to show relevant warnings based on increase vs. decrease.

Scenario-Specific Messages

Rule 2: Vendor Selection Validation

Validation Set: Purchase Line - Vendor Item Validation - OnValidate

Source References:

1. Item Vendor (99000785)
   Link via: [39:6] = [99000785:2]
   Reference Filters:
     [99000785:1] = [38:4]

Condition:


Action - Message:

Type: Warning

Message:
ITEM NOT CONFIGURED FOR THIS VENDOR

Item: [39:6] - [Item:3]
Vendor: [38:79]

This item is not in the vendor's item catalog.

[IF([Item:CustomPreferredVendor] is not '', 
  'Preferred Vendor: ' + [Item:CustomPreferredVendor] + '
   Consider using preferred vendor for better pricing and terms.',
  'No preferred vendor configured.'
)]

[IF([Item:CustomLastPurchaseVendor] is not '',
  'Last Purchased From: ' + [Item:CustomLastPurchaseVendor] + ' on ' + [Item:CustomLastPurchaseDate]

Result: Message provides vendor history and recommendations.

Part 4: Messages for Data Quality

Validation of Data Completeness

Messages can enforce data quality standards by validating required information.

Validation Set: Customer - Data Completeness - OnModify

Rule 1: Validate Critical Customer Fields

Condition:

[18:CustomCreditRating] is ''
OR [18:64] is ''
OR [18:27] is ''
OR [18:CustomSalespersonCode]

Action - Message:

Type: Warning

Message:
INCOMPLETE CUSTOMER INFORMATION

Customer: [18:2]

Missing Required Fields:
[IF([18:CustomCreditRating] is '', '• Credit Rating', '')]
[IF([18:64] is '', '• Payment Method', '')]
[IF([18:27] is '', '• Payment Terms', '')]
[IF([18:CustomSalespersonCode]

Placeholders Used in This Example:

  • [18:2] - Customer (Table 18): Name (Field 2) - Customer name in message

  • [18:CustomCreditRating] - Customer (Table 18): Custom Credit Rating field - Credit rating value

  • [18:64] - Customer (Table 18): Payment Method Code (Field 64) - Payment method

  • [18:27] - Customer (Table 18): Payment Terms Code (Field 27) - Payment terms

  • [18:CustomSalespersonCode] - Customer (Table 18): Custom Salesperson Code field - Assigned salesperson

  • Empty checks: [18:CustomCreditRating] is '', [18:64] is '', etc. - Conditions checking for empty fields

  • OR logic: Multiple conditions evaluated independently, any empty field triggers message

  • Conditional display: IF([18:CustomCreditRating] is '', '• Credit Rating', '') - Shows bullet point only if field empty

  • Message type: Warning - Allows continuation but alerts user to data quality issues

Result: User notified of data quality issues affecting downstream processes.

Data Consistency Validation

Rule 2: Validate Related Field Consistency

Validation Set: Item - Inventory Setup Validation - OnModify

Condition:

Condition 1: {[27:15] > 0 && [27:16] = 0}
// Reorder point set but quantity is zero

Condition 2: {[27:16] > 0 && [27:15] = 0}
// Reorder quantity set but point is zero

Condition 3: [27:16]

Action - Message:

Type: Warning

Message:
INVENTORY PARAMETER INCONSISTENCY

Item: [27:1] - [27:3]

Current Settings:
Reorder Point: [27:15]
Reorder Quantity: [27:16]

Issue Detected:
[IF({[27:15] > 0 && [27:16] = 0},
  'Reorder point set but reorder quantity is zero.
   System will alert when inventory low but no automatic reorder quantity defined.',
  ''
)]

[IF({[27:16] > 0 && [27:15] = 0},
  'Reorder quantity set but reorder point is zero.
   System will not trigger reorder alerts.',
  ''
)]

[IF([27:16] > [27:15] * 10,
  'Reorder quantity (' + [27:16] + ') is significantly larger than reorder point (' + [27:15]

Result: User alerted to potentially problematic configuration with guidance.

Part 5: Multi-Rule Message Coordination

Prioritized Message Display

When multiple rules could trigger messages, prioritize most critical issues.

Validation Set: Sales Order - Comprehensive Validation - OnRelease

Rule 1: Critical Blocking Issues (Priority 1)

Condition:

[Customer:Blocked]

Action - Message:

Type: Error

Message:
CUSTOMER ACCOUNT BLOCKED

Customer: [Customer:2]
Block Reason: [Customer:Blocked]

Rule 2: Credit Issues (Priority 2)

Condition:

[Customer:Blocked] is ' '
AND [Customer:62] > [Customer:59]

Action - Message:

Type: Error

Message:
CREDIT LIMIT EXCEEDED

[Message content...]

Rule 3: Warning Issues (Priority 3)

Condition:

[Customer:Blocked] is ' '
AND [Customer:62] <= [Customer:59]
AND [Customer:CustomLastOrderDate] < [T]

Action - Message:

Type: Warning

Message:
INACTIVE CUSTOMER WARNING

[Message content...]

Result: Most critical issue displayed first, preventing confusion from multiple messages.

Consolidated Message Content

Rule 4: Comprehensive Order Validation

Single message incorporating multiple validation checks.

Condition:

Action - Message:

Type: Warning

Message:
ORDER VALIDATION SUMMARY

Order No.: [36:3]
Customer: [36:79]

Potential Issues Detected:

[IF([36:CustomRequestedShipDate] < [T] + 2,
  '⚠ Rush shipment requested (less than 2 days)
   Expedite fees may apply.',
  ''
)]

[IF([36:64] is 'COD',
  '⚠ COD payment terms selected
   Verify cash collection procedures with warehouse.',
  ''
)]

[IF([Customer:CustomPreferredShipMethod] <> [36:CustomShipMethod],
  '⚠ Ship method differs from customer preference
   Preferred: ' + [Customer:CustomPreferredShipMethod] + '
   Selected: ' + [36:CustomShipMethod],
  ''
)]

[IF(COUNT(37:* WHERE [37:CustomBackordered] is true) > 0,
  '⚠ ' + COUNT(37:*) + ' lines have backordered items
   Partial shipment or delay expected.',
  ''
)]

[IF(ALL issues resolved,
  '✓ No issues detected. Order ready for release.',
  ''
)]

Result: Single comprehensive message consolidates multiple validation checks.

Part 6: Best Practices

Message Design Guidelines

Structure messages clearly:


Provide actionable guidance:


Use appropriate tone:


Message Type Selection

Use Error (blocking) for:

  • Data integrity violations

  • Regulatory compliance failures

  • Operations that would corrupt data

  • Actions exceeding authorization

Use Warning (non-blocking) for:

  • Data quality issues

  • Unusual but valid situations

  • Best practice deviations

  • Recommended but not required actions

Use Information for:

  • Process confirmations

  • Success notifications

  • Helpful tips

  • Procedural reminders

Testing Checklist

Before deploying message actions:

  • Verify message text is clear and professional

  • Confirm field references display correctly

  • Test with null/empty field values

  • Verify conditional message sections show appropriately

  • Check message formatting (line breaks, spacing)

  • Validate calculated values display correctly

  • Test blocking messages prevent operations

  • Confirm warning messages allow continuation

  • Verify messages appear at correct timing

  • Test with various data scenarios

  • Review messages from user perspective

  • Ensure actionable guidance is accurate

Common Patterns

Pattern 1: Validation with Guidance


Pattern 2: Progressive Disclosure


Pattern 3: Data Quality Enforcement


Summary and Key Takeaways

This guide covered custom validation messages using QUALIA Message actions in Microsoft Dynamics 365 Business Central:

  • Basic messages with blocking errors and non-blocking warnings

  • Contextual messages incorporating field values and calculated data

  • Conditional content adapting messages to specific scenarios

  • Data quality enforcement validating completeness and consistency

  • Multi-rule coordination prioritizing and consolidating validation checks

  • Best practices for clear, actionable, professional messaging

Practical applications:

  • Credit limit violation messages with exposure details

  • Inventory shortage alerts with options

  • Price change validation with margin calculations

  • Data completeness enforcement with impact explanation

  • Vendor selection guidance with history

  • Configuration consistency validation

Implementation exercise: Create a comprehensive order validation message:

  1. Identify key validation rules (credit, inventory, pricing, terms)

  2. Design message structure with clear sections

  3. Include specific field values and calculations

  4. Provide actionable corrective guidance

  5. Test with various order scenarios

  6. Refine messaging based on user feedback

Related topics:

  • Blog 017: Multi-Condition Validation (complex validation logic)

  • Blog 024: Aggregate Calculations (calculations in messages)

  • Blog 028: Confirmation Dialogs (confirmations vs. messages)

  • Blog 030: Understanding Scenarios (message timing and triggers)

This blog is part of the QUALIA Rule Engine series for Microsoft Dynamics 365 Business Central. Follow along as we explore business rule automation patterns.

Business Central

>

Triggering Power Automate Flows from Business Rules

>

Advanced Table Linking and Cross-Record Validation

>

Aggregate Calculations Across Related Records: Summing, Counting, and Analyzing Data

>

Automated Email Notifications from Business Rules

>

Automatically Setting Field Values with Assign Actions

>

Building an Approval Workflow: When Orders Need Manager Sign-Off

>

Building Commission Calculation Rules for Sales Teams: Automating Sales Incentives

>

Building Multi-Condition Validation Rules: Understanding Independent Condition Evaluation

>

Construction and Project-Based Industry Solutions

>

Creating Your First Business Rule: A Step-by-Step Beginner's Guide

>

Custom Validation Messages for Business Rules

>

Distribution and Logistics Industry Solutions

>

Energy and Utilities Industry Solutions

>

Financial Services Industry Solutions

>

Food and Beverage Industry Solutions

>

Government and Public Sector Procurement Solutions

>

Healthcare and Medical Supply Industry Solutions

>

How to Implement Credit Limit Validation in 10 Minutes

>

How to Link Multiple Tables for Complex Multi-Table Validation

>

How to Prevent Infinite Loops in Your Business Rules

>

How to Prevent Negative Inventory with Business Rules

>

How to Validate Customer Data Before Order Creation

>

Implementing Discount Authorization Rules: Control Pricing with Confidence

>

Implementing Required Field Validation: Ensuring Data Completeness

>

Interactive Confirmation Dialogs in Business Rules

>

Manufacturing Industry Solutions

>

Non-Profit and Grant Management Solutions

>

Performance Optimization for Business Rules

>

Pharmaceuticals and Life Sciences Solutions

>

Preventing Data Entry Errors: Validation Best Practices

>

Professional Services Industry Solutions

>

Real Estate and Property Management Solutions

>

Retail and Point-of-Sale Industry Solutions

>

Rule Groups and User Permissions: Controlling Who Gets Which Rules

>

Rule Set Organization and Maintenance

>

Rule Versioning and Change Management

>

Testing and Debugging QUALIA Business Rules

>

Transportation and Logistics Industry Solutions

>

Understanding the Rule Execution Pipeline: From Trigger to Action

>

Understanding Validation Scenarios and Timing

>

Using Old Value Placeholders for Change Detection and Validation

Related Posts

Understanding the Rule Execution Pipeline: From Trigger to Action

QUALIA Rule Engine operates as a sophisticated event-driven system that intercepts data changes in Business Central and evaluates configured business rules in real-time. Understanding the execution pipeline—how a database operation flows through trigger detection, scenario evaluation, condition processing, and action execution—is essential for advanced rule design, performance optimization, and troubleshooting.

Energy and Utilities Industry Solutions

Energy and utilities companies face complex regulatory requirements including FERC compliance, NERC reliability standards, environmental regulations, rate case filings, renewable energy credit tracking, interconnection agreements, demand response programs, and outage management protocols. Asset-intensive operations with critical infrastructure, regulatory cost recovery mechanisms, time-of-use pricing structures, and customer meter-to-cash processes demand automated validation beyond standard ERP capabilities.

Real Estate and Property Management Solutions

Real estate and property management companies require specialized business rules for lease administration, tenant billing, common area maintenance (CAM) reconciliation, security deposit tracking, maintenance workflow management, vacancy management, rent escalation calculations, and portfolio performance analysis. Multi-entity property ownership structures, percentage rent calculations, operating expense recoveries, lease abstraction accuracy, and compliance with lease accounting standards (ASC 842 / IFRS 16) demand automated validation beyond standard ERP capabilities.

Get Your FREE Dynamics 365 Demo

Transform your business operations with Microsoft Dynamics 365 Business Central

Experience the transformative power of Microsoft Dynamics 365 Business Central for yourself! Request a free demo today and see how our solutions can streamline your operations and drive growth for your business.

Our team will guide you through a personalized demonstration tailored to your specific needs. This draft provides a structured approach to presenting Qualia Tech's offerings related to Microsoft Dynamics 365 Business Central while ensuring that potential customers understand the value proposition clearly.

Areas Of Interest

Please read and confirm the following:

*Note: Fields marked with * are mandatory for processing your request.

*Note: Fields marked with * are mandatory for processing your request.

© 2024 Qualia. All rights reserved

© 2024 Qualia. All rights reserved

© 2024 Qualia. All rights reserved

© 2024 Qualia. All rights reserved