Chapter 4: Configuring Triggers and Rules
Triggers and scenarios are the intelligence behind notifications—they determine WHEN notifications appear and UNDER WHAT CONDITIONS. This chapter dives deep into trigger configuration, scenario creation, and the Rule Engine's evaluation logic. You'll learn how to monitor specific database events, filter trigger conditions with precision, write complex scenario formulas, and create sophisticated multi-condition rules.
Mastering triggers and scenarios is essential for creating notifications that fire at exactly the right moment with exactly the right context, without overwhelming users with irrelevant alerts.
4.1 Understanding Triggers
What Are Triggers?
Triggers monitor database tables for specific events (Insert, Modify, Delete) and initiate Rule Engine evaluation when those events occur. Without triggers, notifications would never fire—triggers are the mechanism that detects business events.
Trigger Components:
Every trigger configuration includes:
Source Table: Which table to monitor (e.g., Sales Header table 36)
Event Types: Which database operations to watch (Insert, Modify, Delete, Rename)
Field Filters: Optionally, which specific fields matter (Trigger String)
How Triggers Work:
Business Central executes a database operation (user posts an order, modifies a customer, etc.)
The QUALIA Rule Engine has subscribers on table events
When a monitored table changes, the subscriber fires
The Rule Engine checks all triggers configured for that table
Matching triggers initiate notification evaluation
Scenarios check whether conditions are met
If conditions pass, notification displays
📋 NOTE: Triggers are evaluated AFTER the database operation completes and commits. You cannot use triggers to prevent operations or validate data before saving. Triggers are for notification and post-event processing only.
Trigger Types
The Advanced Notification App supports four trigger event types:
Trigger Insert (OnInsert Event):
Fires when a new record is created in the table
Use for: "New order created", "Customer added", "Item registered"
Evaluates the newly inserted record
Trigger Modify (OnModify Event):
Fires when an existing record is changed
Use for: "Order status changed", "Customer credit limit updated", "Item price modified"
Most common trigger type
Can be filtered to specific fields using Trigger String
Trigger Delete (OnDelete Event):
Fires when a record is removed from the table
Use for: "Order cancelled", "Customer deleted", "Item discontinued"
Evaluates the record's state just before deletion
Less common—many BC processes prevent deletion of posted records
Trigger Rename (OnRename Event):
Fires when a record's primary key value changes
Use for: "Document renumbered", "Customer number changed"
Rare in practice—most BC tables don't allow primary key changes after creation
💡 TIP: Start with Trigger Modify for most notifications. It's the most versatile—you can monitor status changes, field updates, and state transitions. Reserve Insert triggers for "new record" scenarios and Delete triggers for cancellation workflows.
Configuring Triggers
Triggers are configured in the Triggers subpage within the notification card's Triggers & Scenarios section.
Procedure: Add a Trigger
Open your notification card
Expand the Triggers & Scenarios section
In the Triggers subpage, click to add a new line
Configure fields:
Source Table No.: Enter the table number to monitor
Trigger Insert: Check if notification should fire on new records
Trigger Modify: Check if notification should fire on record changes
Trigger Delete: Check if notification should fire on record deletions
Trigger Rename: Check if notification should fire on primary key changes
Trigger String: (Optional) Enter comma-separated field numbers to filter modifications
Save the notification
✅ EXAMPLE - Sales Order Released Notification:
Field | Value |
|---|---|
Source Table No. | 36 (Sales Header) |
Trigger Insert | No |
Trigger Modify | Yes |
Trigger Delete | No |
Trigger Rename | No |
Trigger String | 5 (Status field) |
This configuration monitors the Sales Header table and triggers only when the Status field (field 5) is modified, ignoring changes to other fields.
Trigger String Filtering
The Trigger String is a powerful feature that prevents unnecessary evaluations by filtering which field changes matter.
Without Trigger String:
If you check Trigger Modify without specifying a Trigger String:
Notification evaluates on ANY field change
Changing customer name? Evaluates
Changing shipping date? Evaluates
Changing line item quantity? Evaluates
This can result in excessive notifications
With Trigger String:
Specifying field numbers in Trigger String limits evaluation to those fields:
Only evaluates when specified fields change
Dramatically reduces unnecessary processing
Prevents notification spam
Trigger String Syntax:
Enter field numbers as comma-separated values:
Single field:
5Multiple fields:
5,79,110Spaces are ignored:
5, 79, 110works the same
Common Trigger String Examples:
Table | Trigger String | Monitors |
|---|---|---|
36 (Sales Header) | 5 | Status field changes |
36 (Sales Header) | 5,110 | Status or Amount changes |
18 (Customer) | 39 | Blocked field changes |
18 (Customer) | 59,60 | Balance fields change |
27 (Item) | 91 | Unit Price changes |
38 (Purchase Header) | 5 | Purchase status changes |
⚠️ WARNING: Trigger String filtering is case-sensitive to commas and requires exact field numbers. If your trigger never fires, verify:
Field numbers are correct for the source table
No spaces or typos in the trigger string
The field you're monitoring actually changes during your test scenario
When to Use Trigger Strings:
Use Trigger String when:
Monitoring tables with many fields where only specific fields matter
High-traffic tables where changes happen frequently
You want to reduce performance overhead
Skip Trigger String when:
Monitoring Insert/Delete events (Trigger String doesn't apply)
You genuinely care about ANY field change
The table has few fields and changes are infrequent
Multiple Triggers on One Notification
A single notification can have multiple trigger configurations, allowing it to fire from different tables or different events.
Example: Multi-Table Notification
Notification: "Document status changed"
Trigger 1:
Source Table: 36 (Sales Header)
Trigger Modify: Yes
Trigger String: 5
Trigger 2:
Source Table: 38 (Purchase Header)
Trigger Modify: Yes
Trigger String: 5
This notification fires when either sales documents OR purchase documents change status.
Example: Multi-Event Notification
Notification: "Customer record activity"
Trigger:
Source Table: 18 (Customer)
Trigger Insert: Yes
Trigger Modify: Yes
Trigger Delete: Yes
Trigger String: (empty)
This notification fires on any customer record creation, modification, or deletion.
📋 NOTE: When using multiple triggers, scenarios evaluate against the specific record that triggered. If a Sales Header triggers the notification, scenarios reference Sales Header fields. If a Purchase Header triggers it, scenarios reference Purchase Header fields. Design your scenarios accordingly.
4.2 Creating Scenarios
What Are Scenarios?
While triggers determine WHEN to evaluate a notification, scenarios determine WHETHER to display it. Scenarios are conditional expressions that must evaluate to TRUE for the notification to appear.
Scenario Purpose:
Scenarios filter notifications based on data values:
"Only notify if Status = Released"
"Only notify if Amount > $10,000"
"Only notify if Customer is Blocked"
"Only notify during business hours"
Without scenarios, every trigger event would display a notification. Scenarios ensure notifications appear only when conditions warrant.
Scenario Evaluation:
When a trigger fires:
Rule Engine retrieves the record that triggered
Evaluates each scenario formula
Resolves placeholders to actual field values
Calculates the expression
If ALL scenarios evaluate to TRUE, notification displays
If ANY scenario evaluates to FALSE, notification is suppressed
Multiple scenarios use AND logic—all must pass.
Scenario Configuration
Scenarios are configured in the Scenarios subpage within the Triggers & Scenarios section.
Procedure: Add a Scenario
Open your notification card
In the Scenarios subpage, click to add a new line
Enter a Description explaining what this scenario checks
Enter a Validate String containing your condition formula
Save the notification
Scenario Fields:
Description (Text[100]):
Human-readable explanation of the condition
For documentation and troubleshooting
"Status is Released", "Amount exceeds $10,000", "Customer is not blocked"
Validate String (Text[250]):
The actual conditional expression
Uses placeholder syntax
Must evaluate to TRUE or FALSE
"[36:5] = 1", "[36:110] > 10000", "[18:39] <> TRUE"
Scenario Formula Syntax
Scenario formulas use a specific syntax for comparing values:
Basic Comparison Operators:
=Equal to<>Not equal to>Greater than<Less than>=Greater than or equal to<=Less than or equal to
Operand Types:
Placeholders (resolve to field values):
Literals:
Numbers:
1000,10000.50,-50Text:
'Released','APPROVED'(single quotes required)Dates:
'2025-12-31','2025-01-01'(ISO format, single quotes)Booleans:
TRUE,FALSE(no quotes)
Basic Formula Structure:
✅ EXAMPLE - Common Scenario Formulas:
Complex Scenario Formulas
For sophisticated conditions, you can use logical operators and grouping:
Logical AND:
Both conditions must be true (Status is Released AND Amount exceeds 10,000)
Logical OR:
Either condition can be true (Status is Released OR Status is Shipped)
Grouping with Parentheses:
Complex logic: (Status is Released or Shipped) and (Amount exceeds 10,000)
NOT Operator:
Negates the condition (Customer is NOT blocked)
Alternatively: [18:39] <> TRUE achieves the same result
Range Checks:
Amount between 1,000 and 50,000 (inclusive)
⚠️ WARNING: Complex formulas are powerful but can be hard to troubleshoot. Test thoroughly and document what each formula does. Consider splitting very complex scenarios into multiple simpler scenarios or multiple notifications.
Testing Scenario Formulas
Validating scenarios before deployment prevents issues:
Testing Approach:
Create test notification with code "TEST-SCENARIO"
Configure simple trigger on a test table
Add your scenario formula
Create/modify test records that should match
Verify notification appears for matching records
Create records that should NOT match
Verify notification does NOT appear for non-matching records
Common Scenario Errors:
Error: Scenario never passes (notification never displays)
Possible causes:
Formula syntax error (mismatched parentheses, wrong operators)
Wrong field numbers in placeholders
Wrong data type (comparing number to text)
Literal values wrong format (missing quotes on text)
Error: Scenario always passes (notification displays too often)
Possible causes:
Formula logic inverted (using = instead of <>)
Missing parentheses changing evaluation order
Comparing wrong fields
Error: System error when evaluating
Possible causes:
Invalid placeholder syntax
Non-existent table or field numbers
Data type mismatch (comparing date to number)
💡 TIP: Use the QUA Validation Log to troubleshoot scenarios. The log shows whether scenarios passed or failed for each evaluation, helping you understand what's happening.
Multiple Scenarios (AND Logic)
You can add multiple scenario rows to a single notification. All scenarios must evaluate to TRUE for the notification to display—they use AND logic.
Example: Multi-Scenario Notification
Notification: "Large order released"
Scenario 1:
Description: Status is Released
Validate String:
[36:5] = 1
Scenario 2:
Description: Amount exceeds $25,000
Validate String:
[36:110] > 25000
Evaluation:
Trigger fires when Sales Header modified
Scenario 1 checks: Is status Released? If NO → Stop, don't show notification
Scenario 2 checks: Is amount > $25,000? If NO → Stop, don't show notification
Both TRUE → Display notification
This ensures notifications only appear for large released orders, not small released orders or large unreleased orders.
When to Use Multiple Scenarios vs. Complex Formulas:
Multiple Scenarios:
Easier to read and understand
Easier to add/remove conditions
Better for documentation
Each scenario described separately
Complex Formula:
More compact
Can use OR logic between conditions
Better for tightly-coupled logic
Use multiple scenarios when conditions are independent concepts. Use complex formulas when conditions are variations of the same concept.
4.3 Advanced Trigger and Scenario Patterns
Monitoring Status Changes
One of the most common notification patterns is detecting when a record's status field changes to a specific value:
Pattern: Status Change Detection
Configuration:
Trigger: Modify event on source table
Trigger String: Status field number
Scenario: Check for specific status value
Example: Sales Order Released
This fires only when Status field changes AND the new value is 1 (Released).
Why This Works:
The Trigger String ensures evaluation only happens when field 5 changes. The scenario ensures the notification only appears when the new value is Released. Without the scenario, the notification would fire when status changes TO or FROM Released.
Threshold Monitoring
Notifications can alert users when values cross thresholds:
Pattern: Threshold Alert
Example: Customer Credit Limit Exceeded
This compares Balance (LCY) field 59 against Credit Limit (LCY) field 27.
Example: Low Inventory Alert
This compares Inventory against Reorder Point.
📋 NOTE: FlowField triggers can be performance-intensive if FlowFields calculate frequently. Test thoroughly in realistic data volumes. Consider using scheduled batch jobs instead of real-time notifications for non-urgent inventory monitoring.
Time-Based Conditions
Scenarios can check dates and times to create time-sensitive notifications:
Pattern: Date Range Filtering
Example: Orders Due This Week
Example: Overdue Notifications
Supported Date Functions:
TODAY()- Current dateTODAY() + n- n days from nowTODAY() - n- n days ago
💡 TIP: Date-based scenarios evaluate at trigger time. An order due tomorrow will only trigger notifications when the record is modified, not automatically when tomorrow arrives. For automatic daily checks, consider scheduled notifications via job queue entries.
User-Based Filtering
Scenarios can check who performed an action:
Pattern: User Detection
Example: Notify on External User Changes
This checks the Last Modified By user ID and notifies only if it's not the ADMIN user.
Example: Notify Specific User's Activity
This uses pattern matching to detect users with IDs starting with "SALES".
⚠️ WARNING: User ID comparisons are case-sensitive and must match exactly. Verify user ID values in your environment before using in scenarios. BC uses the User Name field (User ID), not the Full Name.
Multi-Table Scenario Patterns
When using related table placeholders, you can create scenarios that check data across relationships:
Pattern: Related Record Filtering
Example: Notify for VIP Customer Orders
This assumes a custom Boolean field 5054 on Customer table marking VIP status. When a sales order status changes, the scenario checks the related customer's VIP flag.
How Related Placeholders Work:
The Rule Engine:
Detects Sales Header trigger
Retrieves the triggered Sales Header record
Follows the relationship to Customer table
Evaluates the Customer field in the scenario
This requires a valid table relation from Sales Header to Customer.
This completes Chapter 4. Users now understand triggers, scenarios, formula syntax, complex conditions, and common notification patterns.
0 Code Advanced Notifications
>
Chapter 01: Introduction & Getting Started
>
Chapter 02: Creating and Managing Notifications
>
Chapter 03: Interactive Notification Actions
>
Chapter 04: Configuring Triggers and Rules
>
Chapter 05: Rule Groups and User Management
>
Chapter 06: Template Management and Troubleshooting
Related Posts
Chapter 06: Template Management and Troubleshooting
Exporting notifications creates XML files containing complete configuration: Why Export: Backup: Save configurations before making changes Version control: Track configuration history
Chapter 05: Rule Groups and User Management
Rule Groups control WHO receives notifications. They filter which users or roles should be notified when a trigger fires and scenarios pass. Without Rule Group assignments, notifications would display to all users, regardless of relevance.
Chapter 04: Configuring Triggers and Rules
Triggers and scenarios are the intelligence behind notifications—they determine WHEN notifications appear and UNDER WHAT CONDITIONS. This chapter dives deep into trigger configuration, scenario creation, and the Rule Engine's evaluation logic. You'll learn how to monitor specific database events, filter trigger conditions with precision, write complex scenario formulas, and create sophisticated multi-condition rules.
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.