Skip to content · Zum Inhalt

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

Introduction

Starting with business rules can feel intimidating—new terminology, multiple configuration screens, unfamiliar concepts, and the pressure of implementing something that will affect live business processes. But it doesn't have to be difficult.

This guide takes you through creating your first business rule from absolute beginning to successful implementation. No prior knowledge required. We'll build a simple but practical rule: preventing salespeople from offering discounts greater than their authorized limit.

By the end of this guide, you'll have created, tested, and activated your first business rule, and you'll understand the fundamental concepts that apply to all rule creation.

What we'll build: A validation rule that checks whether a salesperson's discount on a sales order line exceeds their authorized limit, displays a clear error message if it does, and allows the transaction if it doesn't.

Time required: 20-30 minutes

Prerequisites:

Access to Business Central with QUALIA Rule Engine installed

Permission to create business rules

Understanding of basic Business Central navigation

Let's begin.

Understanding the Scenario

Before creating any rule, clearly understand what you're trying to achieve.

Business Problem

Current situation:

Salespeople can offer any discount to customers

No automatic limit enforcement

Management sets discount limits by salesperson level:

Junior salespeople: up to 10%

Standard salespeople: up to 20%

Senior salespeople: up to 35%

Currently relying on manual review (slow, inconsistent, errors slip through)

Desired situation:

System automatically checks discount against salesperson's limit

Real-time validation when entering sales order

Clear error message if limit exceeded

Manager contact information for approval requests

Rule Requirements

What should the rule do?

✓ Trigger when a sales order line is created or modified ✓ Check the discount percentage on the line ✓ Compare it to the salesperson's authorized discount limit ✓ Allow the transaction if discount is within limit ✓ Block the transaction if discount exceeds limit ✓ Display helpful error message explaining the issue and how to resolve

What data do we need?

Sales Order Line → Discount % field

Salesperson → Maximum discount % (we'll need to add a custom field for this)

Sales Order Header → Salesperson code (to link line to salesperson)

Step 1: Prepare Your Data (5 minutes)

Before creating the rule, ensure the required data fields exist.

Add Salesperson Discount Limit Field

Navigate to:

Search for "Salespeople/Purchasers"

Open the list page

Check if custom field exists:

Look for a field like "Max Discount %" or "Discount Limit"

If it exists, note the field number

If it doesn't exist, you'll need to add it (requires development permission)

For this tutorial, we'll assume you've added a custom field:

Table: 13 (Salesperson/Purchaser)

Field: CustomMaxDiscountPct (Decimal)

Caption: "Max Discount %"

Set values for your salespeople:

Salesperson Code

Name

Max Discount %

JJ

John Johnson

10

SM

Sarah Miller

20

RW

Robert Williams

35

| | | |

|---|---|---|

| | | |

| | | |

| | | |

To set values:

Open Salespeople/Purchasers list

Find salesperson

Enter their Max Discount % (e.g., 10, 20, 35)

Close the page (saves automatically)

Repeat for all salespeople you want to include in the rule.

Step 2: Open Business Rule Sets (1 minute)

Navigate to Business Rule Sets:

In Business Central, open the search function (Alt+Q or click search icon)

Type "Business Rule Sets"

Click on "Business Rule Sets" in the results

The Business Rule Sets list page opens

You'll see existing rule sets (if any) or an empty list if this is your first rule.

Step 3: Create a New Rule Set (3 minutes)

A rule set is a container that holds related rules. Think of it like a folder.

Click "New" to create a new rule set.

Fill in the Header

Code: SALES-DISCOUNT-LIMIT

Unique identifier for this rule set

Use descriptive, uppercase with hyphens

Cannot be changed after saving

Description: Validate Salesperson Discount Limits

Human-readable description

Explains the purpose of this rule set

Can be changed anytime

Trigger Table: 37 - Sales Line

The table where the rule will run

Type "37" or "Sales Line"

This means the rule triggers when sales order lines are created or modified

Trigger Event: Before Insert

When the rule executes

"Before Insert" = runs when creating a new line

We'll also add "Before Modify" to catch changes to existing lines

Add second trigger event:

In the Trigger Event field, notice it may allow multiple selections

Also select "Before Modify"

Now the rule runs on both new lines and modified lines

Enable: ☑ (checked)

Controls whether the rule set is active

Checked = active, unchecked = inactive

Leave checked for now

Priority: 10

Execution order when multiple rule sets trigger

Lower numbers run first

Default 10 is fine for most cases

Understanding Your Choices

Why Sales Line table?

Discount % is entered on sales order lines (not the header)

We need to validate each line individually

Table 37 is the Sales Line table in Business Central

Why Before Insert/Modify?

"Before Insert" catches new lines being added

"Before Modify" catches existing lines being changed

Validating BEFORE saving prevents bad data from entering the system

Alternative "After Insert/Modify" would be too late

Save the rule set header (Ctrl+S or it saves automatically when you navigate away).

Scenarios are filters that determine whether the rules in this set should run at all. They improve performance by skipping rules that don't apply.

Navigate to Scenarios:

On your rule set card, look for "Scenarios" FastTab or section

Click in the scenarios area to add a new line

Scenario 1: Only Order Lines

Field No.: 1

This is "Document Type" field on Sales Line table

Type "1" or use lookup to find "Document Type"

Filter Value: Order

We only want to validate orders (not quotes, invoices, credit memos)

Type "Order"

Why this scenario?

Discount limits apply to orders, not quotes or other document types

This filters out ~50% of transactions, improving performance

Rules below will only run if this scenario is true

Scenario 2: Only Lines with Discounts

Field No.: 11

This is "Line Discount %" field on Sales Line table

Type "11" or use lookup

Filter Value: <>0

Only run rules if discount is not zero

Syntax: "<>0" means "not equal to zero"

Why this scenario?

If there's no discount, no need to validate against limits

Filters out another ~60-70% of transactions

Only lines with actual discounts get validated

Your scenarios should look like:

Field No.

Field Name

Filter Value

1

Document Type

Order

11

Line Discount %

<>0

| | | |

|---|---|---|

| | | |

| | | |

Understanding scenarios:

ALL scenarios must be true for rules to run

Think of scenarios as "If [condition 1] AND [condition 2] AND [condition 3] THEN run rules"

Order doesn't matter

More specific scenarios = better performance

We need to access the Salesperson table to get the max discount limit. We do this through Linked Tables.

Navigate to Linked Tables:

On your rule set card, look for "Linked Tables" section

Click to add a new line

Table No.: 13

Type "13" or search for "Salesperson/Purchaser"

This is the table that stores salesperson data

Link Through Table: 36

Type "36" or search for "Sales Header"

We're linking: Sales Line (37) → Sales Header (36) → Salesperson (13)

Link Field No. (in Sales Line): 1

Field that links Sales Line to Sales Header

Field 1 is "Document Type"

Actually, correction: We need to think about this differently.

Better approach:

Linked Table 1: Sales Header

Table No.: 36

Link Through Table: (blank - direct link)

Link Field No.: 1 (Document Type), 3 (Document No.)

Target Field No.: 1 (Document Type), 3 (No.)

Linked Table 2: Salesperson (through Header)

Table No.: 13

Link Through Table: 36 (Sales Header)

Link Field No.: 43 (Salesperson Code in Sales Header)

Target Field No.: 1 (Code in Salesperson table)

Note: Linked table configuration can be complex. The exact setup depends on how QUALIA Rule Engine handles relationships. Consult documentation or ask your system administrator for assistance with linked tables.

Simplified approach (if available): Some versions allow automatic relationship detection. If prompted, confirm the relationship:

Sales Line → Sales Header (via Document Type + Document No.)

Sales Header → Salesperson/Purchaser (via Salesperson Code)

Step 6: Create the Validation Rule (5 minutes)

Now we create the actual validation logic.

Navigate to Rules:

On your rule set card, look for "Rules" or "Validations" section

Click to add a new rule line

Rule Header

Code: CHECK-DISCOUNT-LIMIT

Unique identifier within this rule set

Descriptive, uppercase with hyphens

Description: Validate Discount Against Salesperson Limit

What this rule does

Rule Type: Validation

Validation = checking data

Other types exist (workflow, calculation) but validation is most common

Enable: ☑ (checked)

Rule is active

The Condition (Formula)

This is the core logic: when is the rule violated?

Navigate to the Formula/Condition field on your rule line.

Our logic:

If Line Discount % > Salesperson Max Discount %

Then error (block transaction)

Formula syntax:

[37:11] is >[13:CustomMaxDiscountPct]

Placeholders Used in This Condition:

[37:11] - Sales Line (Table 37): Line Discount % (Field 11) - The discount percentage entered on this sales order line

[13:CustomMaxDiscountPct] - Salesperson/Purchaser (Table 13): Max Discount % (Custom Field) - The salesperson's authorized discount limit

Breaking this down:

[37:11]:

[37:11] = Table 37 (Sales Line), Field 11 (Line Discount %)

This is the discount entered on this sales order line

> (greater than operator)

[13:CustomMaxDiscountPct]:

[13:CustomMaxDiscountPct] = Table 13 (Salesperson), custom field Max Discount %

This is the salesperson's authorized discount limit

Complete condition: "If the discount on this line is greater than the salesperson's maximum discount percentage, trigger the action below"

Enter this formula in the Condition or Formula field:

[37:11] > [13:CustomMaxDiscountPct]

Understanding Formulas

Placeholder syntax: [TableNo:FieldNo] or [TableNo:FieldName]

Refers to a field value

Gets the value from the current record (or linked record)

Operators:

&gt; Greater than

&lt; Less than

= Equals

&lt;&gt; Not equal

&gt;= Greater than or equal

&lt;= Less than or equal

Combining conditions:

Use multiple Scenarios for AND logic (all must match)

Use multiple Conditions for OR logic (independent)

QUALIA doesn't support AND/OR to combine different fields

Example: Create Scenario 1: [37:11] is &gt;20 and Scenario 2: [37:15] is &gt;100 for AND logic

Step 7: Configure the Error Action (5 minutes)

When the condition is true (discount exceeds limit), what should happen?

Navigate to Actions:

Within your rule, find "Actions" subsection

Add a new action line

Action Setup

Action Type: Error

Error = blocks the transaction, user cannot proceed

Warning = allows override

Message = informational only

Action Code: (may auto-generate or require selection)

If prompted, select "Error" or "ERR" or similar

Message Text: This is what the user sees when they exceed the discount limit. Make it helpful!

Example message:

Discount exceeds authorized limit. 

Salesperson [13:1] ([13:2]) has maximum discount authorization of [13:CustomMaxDiscountPct]%, but this line has discount of [37:11]%.

To proceed:
- Reduce discount to [13:CustomMaxDiscountPct]% or less, or
- Request manager approval from Sales Manager at ext. 5100, or
- Escalate to Sales Director at ext. 5000

Current line: Item [37:6], Quantity [37:15], Unit Price $[37:22], Discount [37:11]

Placeholders Used in This Message:

[13:1] - Salesperson/Purchaser (Table 13): Code (Field 1) - Salesperson's code

[13:2] - Salesperson/Purchaser (Table 13): Name (Field 2) - Salesperson's full name

[13:CustomMaxDiscountPct] - Salesperson/Purchaser (Table 13): Max Discount % (Custom Field) - Salesperson's authorized discount limit

[37:11] - Sales Line (Table 37): Line Discount % (Field 11) - The discount entered on this line

[37:6] - Sales Line (Table 37): No. (Field 6) - Item number

[37:15] - Sales Line (Table 37): Quantity (Field 15) - Quantity ordered

[37:22] - Sales Line (Table 37): Unit Price (Field 22) - Price per unit

Enter this message in the Action Message or Description field.

Understanding Placeholders in Messages

[13:1]: Salesperson Code [13:2]: Salesperson Name [13:CustomMaxDiscountPct]: Max Discount % [37:11]: Line Discount % [37:6]: Item No. [37:15]: Quantity [37:22]: Unit Price

Placeholders get replaced with actual values when the message displays:

Instead of "[13:1]", user sees "JJ"

Instead of "[13:2]", user sees "John Johnson"

Instead of "[13:CustomMaxDiscountPct]", user sees "10"

Result: User sees specific, actionable information about their exact situation.

Step 8: Save and Review (2 minutes)

Save your work:

Ctrl+S or close the page (auto-saves)

Review your configuration:

Rule Set Header:

Code: SALES-DISCOUNT-LIMIT

Description: Validate Salesperson Discount Limits

Trigger Table: 37 - Sales Line

Trigger Event: Before Insert, Before Modify

Enable: Yes

Scenarios:

[37:1] = 'Order' (Document Type is Order)

[37:11] <> 0 (Discount % is not zero)

Linked Tables:

Table 36 (Sales Header)

Table 13 (Salesperson/Purchaser)

Rule:

Code: CHECK-DISCOUNT-LIMIT

Condition: [37:11] is >[13:CustomMaxDiscountPct]

Action:

Type: Error

Message: [Detailed message with placeholders]

Everything look correct? Proceed to testing.

Step 9: Test Your Rule (10 minutes)

Testing is critical. Never deploy a rule without testing.

Test Case 1: Discount Within Limit (Should PASS)

Setup:

Salesperson: JJ (John Johnson) with 10% max discount

Expected: Discount of 10% or less should be allowed

Steps:

Create a new Sales Order (Document Type = Order)

Select Customer (any customer)

Select Salesperson Code: JJ

Add a new line:

Item: Select any item

Quantity: 10

Unit Price: Will auto-fill

Enter Line Discount %: 10 (exactly at limit)

Tab to next field or try to save

Expected Result:

✓ No error message

✓ Line saves successfully

✓ Order can be processed

Actual Result: _____________

Test Case 2: Discount Exceeds Limit (Should FAIL)

Setup:

Same salesperson: JJ with 10% max

Expected: Discount of 15% should be blocked

Steps:

On same order or new order with salesperson JJ

Add a line

Enter Line Discount %: 15 (exceeds limit)

Tab to next field

Expected Result:

✓ Error message displays

✓ Message shows:

Salesperson code and name

Max discount (10%)

Attempted discount (15%)

Line details

Resolution options

✓ Cannot save line with this discount

Actual Result: _____________

Verify message content:

Are placeholders resolving to actual values?

Is salesperson name showing correctly?

Are percentages accurate?

Is the message clear and helpful?

Test Case 3: Higher Limit Salesperson (Should PASS)

Setup:

Salesperson: RW (Robert Williams) with 35% max

Expected: Discount of 30% should be allowed

Steps:

Create new order with salesperson RW

Add line

Enter Line Discount %: 30

Tab to next field

Expected Result:

✓ No error

✓ Line saves (30% is less than 35% limit)

Actual Result: _____________

Test Case 4: No Discount (Should SKIP Rule)

Setup:

Any salesperson

Expected: Line with no discount should not trigger rule

Steps:

Create new order

Add line

Leave Line Discount % blank (0%)

Save line

Expected Result:

✓ No error

✓ Line saves

✓ Rule didn't even run (scenario filtered it out)

Actual Result: _____________

Test Case 5: Quote Document Type (Should SKIP Rule)

Setup:

Document Type: Quote (not Order)

Expected: Rule should not run on quotes

Steps:

Create a new Sales Quote (not order)

Select salesperson JJ (10% max)

Add line

Enter Line Discount %: 50 (way over limit)

Save line

Expected Result:

✓ No error

✓ Line saves (scenario filters out non-Order documents)

Actual Result: _____________

Test Results Summary

Test Case

Expected

Actual

Pass/Fail

  1. Within limit (10%)

Allow

  1. Exceeds limit (15%)

Block with error

  1. Higher limit (30% vs 35%)

Allow

  1. No discount (0%)

Allow, rule skipped

  1. Quote document type

Allow, rule skipped

| | | | |

|---|---|---|---|

| | | | |

| | | | |

| | | | |

| | | | |

| | | | |

All tests passed? ✓ Your rule is working correctly!

Some tests failed? See Troubleshooting section below.

Step 10: Activate and Monitor (2 minutes)

Once testing is complete and successful:

Ensure rule is enabled:

Open your rule set

Verify "Enable" is checked

Save

Communicate to users:

Email sales team: "New automated discount limit validation is active"

Explain what will happen when they exceed limits

Provide manager contact for approvals

Set expectations

Monitor initial usage:

First few days, watch for user questions

Are error messages clear?

Any unexpected scenarios?

Performance acceptable?

Refine as needed:

Adjust message wording based on feedback

Add scenarios if rule triggers too often

Modify limits if business rules change

Troubleshooting

Issue 1: Rule Doesn't Trigger at All

Symptoms:

Enter high discount, no error appears

Rule never runs

Check:

Rule Set enabled? Verify "Enable" is checked on rule set header

Rule enabled? Verify "Enable" is checked on individual rule

Scenarios too restrictive?

Check scenario filters

Try temporarily removing scenarios to see if rule runs

Trigger event correct? Should be "Before Insert" and "Before Modify"

Trigger table correct? Should be Table 37 (Sales Line)

Issue 2: Error Shows But Placeholders Don't Resolve

Symptoms:

Error displays but shows "[13:CustomMaxDiscountPct]" instead of "10"

Check:

Linked tables configured? Must link Sales Line → Sales Header → Salesperson

Field names correct? Verify custom field name exactly matches

Syntax correct? Should be [TableNo:FieldName] or [TableNo:FieldNo]

Fix: Double-check linked table configuration and field names

Issue 3: Error Triggers When It Shouldn't

Symptoms:

Discount within limit but error still appears

Check:

Condition logic correct? Should be &gt; (greater than), not &gt;= (greater or equal)

Salesperson max discount set? Check Salesperson card has value in Max Discount % field

Correct salesperson linked? Verify order has correct salesperson code

Debug: Temporarily change condition to display values:

Action Type: Message (instead of Error)
Message: "Line discount: [37:11], Max allowed: [13:CustomMaxDiscountPct]

This shows actual values being compared

Issue 4: Performance Issues (Slow)

Symptoms:

Adding sales lines is noticeably slower

Check:

Scenarios present? Should have scenarios to filter transactions

Too many linked tables? Only link tables actually needed

Complex formula? Keep conditions simple

Fix:

Add/optimize scenarios

Remove unnecessary linked tables

Simplify condition logic

Issue 5: Rule Triggers on Wrong Document Types

Symptoms:

Rule runs on quotes, invoices, etc.

Check:

Scenario filtering document type? Should have scenario: [37:1] = 'Order'

Fix: Add scenario to filter document type

Key Concepts Recap

Rule Set

Container for related rules. Has trigger table and trigger event.

Trigger Table

Which table the rule monitors (e.g., Sales Line, Customer, Item).

Trigger Event

When the rule runs:

Before Insert: Creating new record

Before Modify: Changing existing record

After Insert: After new record created

After Modify: After existing record changed

Before Delete: Before record deleted

Scenarios

Filters that determine if rules should run. Like "If" conditions before the main rule logic.

Linked Tables

Additional tables you need to access in your rule (besides the trigger table).

Rule

The actual validation logic and actions.

Condition

The formula that determines when the rule triggers. If condition is TRUE, actions execute.

Action

What happens when condition is true:

Error: Blocks transaction

Warning: Allows override

Message: Informational

Email: Send notification

Assign: Set field value

Many others

Placeholders

Dynamic values in messages: [TableNo:FieldNo] or [TableNo:FieldName]

What You've Learned

By completing this guide, you now understand:

✓ How to create a rule set with appropriate trigger table and events ✓ How to use scenarios to filter when rules run ✓ How to link additional tables for accessing related data ✓ How to write simple condition formulas using placeholder syntax ✓ How to configure error actions with helpful, detailed messages ✓ How to use placeholders to show dynamic data in messages ✓ How to test rules with multiple test cases ✓ How to troubleshoot common issues

Next Steps

Expand this rule:

Add email notification to sales manager when limit exceeded

Create warning at 90% of limit before hitting hard stop

Add override capability for senior managers

Track discount exceptions in a log

Create new rules:

Credit limit validation

Inventory availability checking

Required field validation

Customer address verification

Learn advanced concepts:

Complex formulas with calculations

Multiple independent conditions in one rule set

Workflow rules with multiple actions

Integration with Power Automate

Best practices:

Always test thoroughly before activating

Start simple, add complexity gradually

Use clear, helpful error messages

Document your rules for future reference

Monitor and refine based on user feedback

Conclusion

Congratulations! You've created, tested, and deployed your first business rule. What seemed complex at the beginning is now a structured, understandable process:

Understand the business requirement

Prepare necessary data

Create rule set with trigger configuration

Add scenarios for filtering

Link additional tables

Write validation condition

Configure action with clear message

Test thoroughly

Activate and monitor

Refine as needed

This same process applies to virtually all business rules, from simple validations to complex multi-step workflows. The principles you've learned here are the foundation for building sophisticated, powerful business rule automation.

Remember: Start simple, test thoroughly, communicate clearly, and iterate based on feedback. Business rules are living configurations that evolve with your business needs.

You're now ready to solve real business problems with automated, consistent, maintainable business rules.Related Reading:

Understanding Trigger Events: When Should Rules Run?

The Complete Guide to Placeholders in Business Rules

Writing Effective Error Messages for Better User Experience

Scenarios vs Conditions: Two-Tier Validation Architecture