Chapter 4: Configuring Rules and Conditions
This chapter explores the rule engine that determines when flow triggers execute. You'll learn how triggers monitor Business Central tables, how scenarios add conditional logic, and how rule groups filter by user or role. Mastering these concepts allows you to create sophisticated, targeted integrations that fire only when specific conditions are met.
By the end of this chapter, you'll be able to configure complex trigger patterns, write conditional scenarios, optimize performance, and troubleshoot rule evaluation issues.
4.1 Understanding Triggers
What Are Triggers?
Triggers define which Business Central events activate a flow trigger. A trigger specification includes:
Source Table: Which BC table to monitor (e.g., Sales Header, Customer)
Event Type: What action to watch for (Insert, Modify, Delete)
Trigger String: (Optional) Specific fields that must change
Without triggers configured, a flow trigger never fires—it has no events to monitor.
Architecture:
The rule engine continuously monitors configured tables. When an event occurs, it checks all flow triggers with matching table/event combinations.
Trigger Configuration Fields
The Triggers subpage on the flow trigger card contains these fields:
Source Table No.
Integer field
Specifies which BC table to monitor
Examples:
18 = Customer
36 = Sales Header
38 = Purchase Header
112 = Posted Sales Invoice Header
27 = Item
Use assist-edit (…) to search tables by name
Validates that table exists
Insert
Boolean checkbox
When checked: Trigger fires when new record created
Example: New customer created, new sales order created
Use for "record created" events
Modify
Boolean checkbox
When checked: Trigger fires when existing record modified
Example: Customer address updated, order status changed
Use for "record updated" events
Delete
Boolean checkbox
When checked: Trigger fires when record deleted
Example: Customer deleted, order cancelled
Use with caution—deleted records have limited field access
Trigger String
Text field (250 characters)
Optional filter on specific fields
Format: Comma-separated field numbers
Example: 3,79,110 monitors fields 3, 79, and 110
Leave blank to trigger on ANY field change
Use to reduce unnecessary triggers
📋 NOTE: You can enable multiple event types on one trigger line (e.g., both Insert and Modify). The flow trigger fires when any checked event occurs. This is useful for "record created or updated" scenarios.
Configuring Basic Triggers
Example 1: Customer Created
Monitor when new customers are added:
On flow trigger card, locate Triggers subpage
Click in empty line (or press Ctrl+N in subpage)
Source Table No.: Enter 18 (or use lookup for "Customer")
Check Insert
Leave Modify and Delete unchecked
Trigger String: Leave blank (all new customers)
Result: Flow trigger fires every time a user creates a customer.
Example 2: Sales Order Status Changed
Monitor when sales order status changes (e.g., from Open to Released):
Source Table No.: 36 (Sales Header)
Check ModifyTrigger String: 5 (field 5 is Status)
Result: Flow trigger fires only when Status field changes, not when other fields like Ship-to Address change.
Example 3: Item Inventory Changed
Monitor inventory quantity changes:
Source Table No.: 27 (Item)
Check ModifyTrigger String: 99 (field 99 is Inventory)
Result: Flow trigger fires when inventory quantity changes, ignoring changes to description, price, etc.
Example 4: Posted Invoice Created
Monitor all posted sales invoices:
Source Table No.: 112 (Posted Sales Invoice Header)
Check InsertTrigger String: Blank
Result: Flow trigger fires every time an invoice is posted.
Example 5: Multiple Events
Monitor both creation and modification of purchase orders:
Source Table No.: 38 (Purchase Header)
Check both Insert and ModifyTrigger String: Blank
Result: Flow trigger fires when purchase orders are created OR modified.
Multiple Triggers on One Flow Trigger
A single flow trigger can have multiple trigger lines, monitoring different tables or events:
Example: Sales and Purchase Orders
Result: One flow trigger fires for both sales and purchase order events. Useful when Power Automate flow handles multiple document types.
⚠️ WARNING: When using multiple triggers, ensure your JSON payload uses placeholders that exist in ALL monitored tables. For example, both Sales Header (36) and Purchase Header (38) have field 3 (No.), so [36:3] and [38:3] both work. But if you reference a field unique to one table, the webhook will fail when triggered from the other table.
Solution for Table-Specific Placeholders:
Create separate flow triggers for each table:
PA-SALES-001: Monitors table 36, uses Sales Header placeholders
PA-PURCH-001: Monitors table 38, uses Purchase Header placeholders
Both can call the same Power Automate webhook URL if the JSON structure is compatible.
Trigger String Syntax
The Trigger String field filters triggers to specific field changes.
Syntax Rules:1. Single Field
Triggers only when field 5 changes.
2. Multiple Fields (Comma-Separated)
Triggers when field 5 OR 79 OR 110 changes.
3. Spaces Ignored
Same as above—spaces after commas are ignored.
4. Blank (All Fields)
Triggers when ANY field in the record changes.
📋 NOTE: Trigger String is an OR condition. If you list fields 5,79,110, the trigger fires if field 5 changes OR field 79 changes OR field 110 changes. You cannot specify AND logic (field 5 AND 79 must both change). For AND logic, use scenarios.
When to Use Trigger String:Use Trigger String When:
You want to ignore most field changes (performance optimization)
You're monitoring high-volume tables
You only care about specific fields (status, amount, blocked)
You want to reduce noise in validation logs
Leave Blank When:
You're monitoring low-volume tables
Any field change is relevant
You're unsure which fields might change
You're starting out (add filtering later if needed)
Common Field Numbers for Trigger Strings:Sales Header (36):
5 = Status (Open, Released, Pending Approval)
110 = Amount Including VAT
79 = Sell-to Customer Name
Customer (18):
39 = Blocked (status changes)
59 = Balance (LCY)
27 = Credit Limit (LCY)
Item (27):
99 = Inventory
18 = Unit Price
22 = Reorder Point
Purchase Header (38):
5 = Status
110 = Amount Including VAT
💡 TIP: Start with blank Trigger String. Monitor validation logs to see how often the trigger fires. If it's firing too often on irrelevant changes, add a Trigger String to filter to specific fields.
Trigger Evaluation Logic
Processing Flow:
Performance Considerations:
Rule engine evaluates triggers on every relevant table event
Keep trigger count reasonable (dozens, not hundreds)
Use Trigger String to reduce unnecessary evaluations
Avoid monitoring very high-volume tables unless necessary
Example Evaluation:Configuration:
Test Cases:Case 1: User changes Status (field 5) on Sales Order
Event: Table 36, Modify, Field 5
Match: ✓ Table matches, Modify checked, Field 5 in Trigger String
Result: Trigger fires
Case 2: User changes Ship-to Address (field 8) on Sales Order
Event: Table 36, Modify, Field 8
Match: ✗ Field 8 NOT in Trigger String (5,110)
Result: Trigger does NOT fire
Case 3: User creates new Sales Order
Event: Table 36, Insert
Match: ✗ Insert not checked (only Modify checked)
Result: Trigger does NOT fire
Case 4: User changes Amount (field 110) on Sales Order
Event: Table 36, Modify, Field 110
Match: ✓ Table matches, Modify checked, Field 110 in Trigger String
Result: Trigger fires
This precision targeting ensures flow triggers fire only when intended.
4.2 Creating Scenarios
What Are Scenarios?
While triggers determine which events to monitor, scenarios add conditional logic. Scenarios answer: "Should this flow trigger fire for THIS SPECIFIC RECORD?"
Example without Scenario:
Example with Scenario:
Trigger: Sales Header, Insert
Scenario: [36:110]
Scenarios use formula syntax to evaluate field values and decide whether to proceed with the webhook.
Architecture:
Trigger Match → Scenario Evaluation → Pass? → Webhook
↓
Formula: [36:110]
Scenario Configuration Fields
The Scenarios subpage on the flow trigger card contains:
Formula
Text field (250 characters)
Contains conditional expression
Uses placeholder syntax: [TableNo:FieldNo]
Must evaluate to TRUE or FALSE
Examples:
[36:110] > 10000
[18:39] = 'Yes'
[27:99] < [27:22]
Description
Text field
Human-readable explanation
Appears in validation logs
Examples:
"Amount over $10,000"
"Customer is blocked"
"Inventory below reorder point"
Helps with debugging and documentation
Priority
Integer field
Controls evaluation order (lower number = higher priority)
Useful with multiple scenarios
Default: 0
📋 NOTE: All scenarios on a flow trigger must evaluate to TRUE for the webhook to fire. If you have 3 scenarios, all 3 must pass. Scenarios are combined with AND logic, not OR logic.
Scenario Formula Syntax
Comparison Operators:Greater Than (**>**)
[36:110]Fires if Amount Including VAT exceeds 10,000.
Greater Than or Equal (**>=**)
[18:59] >= [18:27]Fires if customer balance >= credit limit.
Less Than (**<**)
[27:99] < [27:22]Fires if inventory is below reorder point.
Less Than or Equal (**<=**)
[36:110]Fires if amount is $5,000 or less.
Equal (**=**)
[36:5]Fires if Status equals "Released".
[18:39]Fires if customer is blocked.
Not Equal (**<>**)
[36:91]Fires if currency is NOT USD.
Logical Operators:AND
[36:110] > 10000 AND [36:5]Both conditions must be true.
OR
[18:39] = 'Yes' OR [18:59] > [18:27]Either condition can be true.
NOT
NOT [36:5]Status must NOT be "Open".
Parentheses for Grouping:
([36:110] > 10000 OR [36:91] <> 'USD') AND [36:5]Complex logic with clear precedence.
Field Comparisons:
Compare two fields from the same record:
[18:59] > [18:27]Balance exceeds credit limit.
[27:99] < [27:22]Inventory below reorder point.
Text Comparisons:Case-Sensitive Equality:
[36:5]Must match exactly: "Released" (not "released" or "RELEASED").
Wildcards (Limited Support):
[18:2]Customer name starts with "A".
Check QUALIA Core documentation for wildcard support in your version.
📋 NOTE: Text values must be enclosed in single quotes ('...'). Numeric values do not use quotes. Boolean fields use 'Yes' or 'No' (quoted). Dates use ISO 8601 format in quotes: '2025-12-09'.
Common Scenario Patterns
Pattern 1: Amount Threshold
Formula: [36:110]
Use for approval workflows, special handling, executive notifications.
Pattern 2: Status-Based
Formula: [36:5]
Trigger only at specific workflow stages.
Pattern 3: Blocked Customer
Formula: [18:39]
Alert sales team when blocked customers attempt orders.
Pattern 4: Inventory Alert
Formula: [27:99] < [27:22]
Automatic reorder notifications.
Pattern 5: Credit Limit Exceeded
Formula: [18:59] > [18:27]
Trigger credit review workflows.
Pattern 6: Foreign Currency
Formula: [36:91]
Special handling for international orders.
Pattern 7: VIP Customer
Formula: [36:2] = 'C-10000' OR [36:2] = 'C-10001' OR [36:2]
Priority handling for key accounts.
Pattern 8: Time-Sensitive (Due Soon)
Formula: [36:20]
Urgency alerts.
Pattern 9: Multi-Condition
Formula: [36:110] > 10000 AND [36:5] = 'Released' AND [36:91]
Precise targeting with multiple criteria.
Pattern 10: Exception Handling
Formula: [36:110] > 10000 AND NOT [36:29]
Ensure proper assignment before processing.
Multiple Scenarios (AND Logic)
A flow trigger can have multiple scenario lines. ALL scenarios must evaluate to TRUE for the webhook to fire.
Example: High-Value USD Orders from Non-Blocked Customers
Scenario 1:
Formula: [36:110] > 10000
Description: Amount over $10,000
Scenario 2:
Formula: [36:91] = 'USD'
Description: Currency is USD
Scenario 3:
Formula: NOT [18:39]
Evaluation:
Why Use Multiple Scenarios Instead of AND in Formula?Option 1: Single Scenario with AND
Formula: [36:110] > 10000 AND [36:91] = 'USD' AND NOT [18:39]
Option 2: Multiple Scenarios
Scenario 1: [36:110] > 10000 → Amount over $10,000
Scenario 2: [36:91] = 'USD' → Currency is USD
Scenario 3: NOT [18:39]
Option 2 is better because:
Validation logs show which scenario failed
Easier to troubleshoot
Easier to modify one condition without rewriting entire formula
More readable
💡 TIP: Use multiple simple scenarios rather than one complex formula with many AND conditions. This improves troubleshooting and maintenance.
Scenario Evaluation and Debugging
When Scenarios Fail:
The validation log shows which scenario failed:
Validation Log Entry:
Flow Trigger: PA-00001
Status: Skipped
Reason: Scenario failed - "Amount over $10,000"
Record: Sales Header SO-1001
Scenario Formula: [36:110]
This helps identify why a webhook didn't fire when expected.
Testing Scenarios:1. Start Without Scenarios
Configure trigger only
Verify trigger fires on table events
Check validation log for all firings
2. Add First Scenario
Add simplest condition
Test with records that should pass
Test with records that should fail
Verify validation log shows correct evaluation
3. Add Additional Scenarios
Add one at a time
Test after each addition
Verify AND logic works correctly
4. Test Edge Cases
Boundary values (exactly 10000, not just over/under)
Empty/null fields
Special characters in text fields
Different data types
Common Scenario Mistakes:Mistake 1: Wrong Quote Type
// Wrong - double quotes
[36:5] = "Released"
// Correct - single quotes
[36:5]
Mistake 2: Missing Quotes on Text
// Wrong - text without quotes
[36:5] = Released
// Correct
[36:5]
Mistake 3: Quotes on Numbers
// Wrong - treats as text
[36:110] > '10000'
// Correct - numeric comparison
[36:110]
Mistake 4: Case Sensitivity
// Wrong - case doesn't match
[36:5] = 'released'
// Correct - exact case
[36:5]
Mistake 5: Invalid Field Reference
// Wrong - field doesn't exist in table
[36:999] > 0
// Correct - valid field number
[36:110]
⚠️ WARNING: If a scenario references a field that doesn't exist or is blank/null, the scenario may fail evaluation or throw an error. Always test with realistic data including edge cases.
4.3 Advanced Trigger Patterns
Status Change Detection
Monitor when specific status fields change to specific values.
Example: Sales Order Released
Trigger:
Source Table: 36 (Sales Header)
Modify: ✓
Trigger String: 5
Scenario:
Formula: [36:5]
Result: Fires when user releases a sales order (status changes from Open to Released).
Why This Works:
Trigger String 5 ensures trigger only fires when Status field changes
Scenario [36:5] = 'Released' ensures the new value is "Released"
Won't fire when status changes from Released to other values
Example: Customer Blocked
Trigger:
Source Table: 18 (Customer)
Modify: ✓
Trigger String: 39
Scenario:
Formula: [18:39]
Alerts when a customer account is blocked.
Threshold Monitoring
Trigger when numeric values cross thresholds.
Example: Low Inventory Alert
Trigger:
Source Table: 27 (Item)
Modify: ✓
Trigger String: 99
Scenario:
Formula: [27:99] < [27:22]
Result: Fires when inventory drops below the reorder point.
Example: Credit Limit Warning
Trigger:
Source Table: 18 (Customer)
Modify: ✓
Trigger String: 59
Scenario:
Formula: [18:59] >= [18:27]
Result: Early warning when customer approaches credit limit.
📋 NOTE: You can use arithmetic in scenario formulas: * (multiply), / (divide), + (add), - (subtract). Example: [18:27] * 0.9 calculates 90% of credit limit.
Time-Based Patterns
Trigger based on date comparisons.
Example: Overdue Orders
Trigger:
Source Table: 36 (Sales Header)
Modify: ✓
Trigger String: (blank)
Scenario:
Formula: [36:20]
Result: Fires when an order's shipment date has passed.
Example: Orders Due Soon
Scenario:
Formula: [36:20]
Result: Alert for orders due in the next week.
Date Functions:
TODAY: Current date
TODAY + 7: 7 days from now
TODAY - 30: 30 days ago
⚠️ WARNING: Date-based triggers with Modify events can fire repeatedly if the record is modified after the date condition becomes true. Consider adding additional scenarios to prevent duplicate notifications (e.g., check a "Notified" flag field).
User-Based Patterns
Trigger based on who performed the action or who owns the record.
Example: Specific Salesperson Orders
Scenario:
Formula: [36:29] = 'SP001' OR [36:29]
Example: Exclude System User
Scenario:
Formula: NOT [36:30]
Prevents triggers from firing on batch jobs or automated processes.
Multi-Table Patterns
Use multiple triggers to monitor related tables.
Example: Sales Order Posted - Monitor Document Creation
Result: One flow trigger fires when either an invoice is posted OR a shipment is created.
💡 TIP: When monitoring multiple related tables, ensure the JSON payload uses placeholders compatible with all tables, or create separate flow triggers for each table with table-specific payloads.
Exception Patterns
Trigger on unusual or problematic conditions.
Example: Orders Without Salesperson
Trigger:
Source Table: 36 (Sales Header)
Insert: ✓
Scenario:
Formula: [36:29]
Result: Alert when orders are created without proper assignment.
Example: Negative Inventory
Trigger:
Source Table: 27 (Item)
Modify: ✓
Trigger String: 99
Scenario:
Formula: [27:99]
Result: Alert on inventory issues.
Example: Duplicate Detection
While BC typically prevents duplicates, custom fields might allow them:
Scenario:
Formula: [18:5] = [18:5]
For duplicate detection, consider using Power Automate flow logic to query BC and check for existing records.
4.4 Multi-Condition Logic
Combining AND and OR Logic
Complex business rules often require both AND and OR operators.
Example: High-Value International Orders
Scenario:
Formula: ([36:110] > 10000 OR [36:110] > 5000 AND [36:91] = 'EUR') AND [36:5]
Evaluation:
(Amount > $10,000 OR (Amount > $5,000 AND Currency = EUR)) AND Status = Released
This triggers for:
USD orders over $10,000 that are released
EUR orders over $5,000 that are released
Use Parentheses for Clarity:
// Ambiguous
[36:110] > 10000 OR [36:91] = 'EUR' AND [36:5] = 'Released'
// Clear
([36:110] > 10000 OR [36:91] = 'EUR') AND [36:5] = 'Released'
// Different meaning
[36:110] > 10000 OR ([36:91] = 'EUR' AND [36:5]
Operator Precedence (Without Parentheses):
NOT
AND
OR
Always use parentheses to make intent explicit.
Nested Conditions
Build sophisticated logic with nesting.
Example: Tiered Approval Requirements
Scenario 1:
Formula: [36:110] <= 5000
Description: Standard approval (under $5K)
Scenario 2:
Formula: ([36:110] > 5000 AND [36:110] <= 20000) AND [36:29] <> ''
Description: Manager approval ($5K-$20K with salesperson)
Scenario 3:
Formula: [36:110] > 20000 AND [36:29] <> '' AND [36:2]
Create three separate flow triggers (one per tier) with different webhook URLs going to different approval flows in Power Automate.
NOT Operator Patterns
Example: Exclude Specific Customers
Scenario:
Formula: NOT ([36:2] = 'C-TEST01' OR [36:2]
Example: Non-Standard Status
Scenario:
Formula: NOT [36:5] = 'Open' AND NOT [36:5]
Triggers for unexpected statuses, useful for error detection.
Performance Optimization for Complex Logic
Guideline 1: Put Fastest Conditions First
// Good - check status first (fast), then complex calculation
[36:5] = 'Released' AND [36:110] > [36:120] * 1.1
// Less optimal - complex calculation first
[36:110] > [36:120] * 1.1 AND [36:5]
The rule engine can short-circuit: if first condition is FALSE, it skips evaluating remaining conditions.
Guideline 2: Avoid Redundant Checks
// Redundant
[36:110] > 10000 AND [36:110] > 5000
// Simplified
[36:110]
Guideline 3: Use Multiple Scenarios for Complex AND Logic
// One complex scenario (harder to debug)
[36:110] > 10000 AND [36:91] = 'USD' AND [36:5] = 'Released' AND NOT [18:39] = 'Yes'
// Multiple simple scenarios (easier to debug)
Scenario 1: [36:110] > 10000
Scenario 2: [36:91] = 'USD'
Scenario 3: [36:5] = 'Released'
Scenario 4: NOT [18:39]
Guideline 4: Limit Trigger Firings with Trigger String
Don't rely only on scenarios to filter events. Use Trigger String to prevent unnecessary trigger evaluations.
// Suboptimal - triggers on ANY field change, scenario filters
Trigger String: (blank)
Scenario: [36:5] = 'Released'
// Optimal - triggers only on Status changes
Trigger String: 5
Scenario: [36:5]
💡 TIP: Profile your integrations by reviewing validation logs. If you see many "Scenario failed" entries, consider refining your Trigger String to reduce unnecessary evaluations.
4.5 Performance Optimization
Understanding Performance Impact
Every configured flow trigger adds processing overhead:
Processing Steps Per Event:
On high-volume tables (Item, Sales Line, General Ledger Entry), this overhead multiplies.
Optimization Strategies
Strategy 1: Use Trigger StringBefore:
Trigger:
Source Table: 36
Modify: ✓
Trigger String: (blank)
Scenario:
Formula: [36:5]
Fires on EVERY field change, then scenario filters. If users modify 10 fields per order, this evaluates scenario 10 times.
After:
Trigger:
Source Table: 36
Modify: ✓
Trigger String: 5
Scenario:
Formula: [36:5]
Evaluates only when Status changes—potentially 90% reduction.
Strategy 2: Combine Related Flow TriggersBefore (3 separate flow triggers):
After (1 flow trigger with OR logic):
PA-SALES-001: High-value orders (all currencies)
Scenario: [36:110] > 10000 AND ([36:91] = 'USD' OR [36:91] = 'EUR' OR [36:91]
Reduces trigger count and evaluation overhead.
Strategy 3: Avoid Monitoring High-Volume TablesHigh-Volume Tables (Be Cautious):
Sales Line (37) - thousands of changes per day
Purchase Line (39)
General Ledger Entry (17)
Item Ledger Entry (32)
Prefer Header Tables:
Sales Header (36) instead of Sales Line (37)
Purchase Header (38) instead of Purchase Line (39)
If you must monitor line tables, use very specific Trigger Strings and scenarios.
Strategy 4: Disable Unused Flow Triggers
If a flow trigger is no longer needed:
Open the flow trigger card
Delete trigger lines (or clear the triggers subpage)
Or delete the entire flow trigger
Don't leave inactive configurations enabled—they still consume processing cycles.
Strategy 5: Batch Notifications
Instead of triggering on every record:
Use scheduled jobs to process in batches
Create summary notifications (e.g., daily digest)
Reduce real-time overhead
For Example:
Instead of: Webhook on every new customer (could be 100/day)
Consider: Daily summary at 5 PM with count and list
Strategy 6: Optimize ScenariosSlow:
Scenario: [36:110] > [36:120] * 1.1 + [36:121]Complex calculation on every evaluation.
Faster:
Scenario: [36:110]Simple comparison.
Strategy 7: Monitor Validation Logs
Regularly review logs for:
High failure rates (refine scenarios)
Frequent "Scenario failed" (adjust Trigger String)
Timeout errors (investigate network/Power Automate performance)
Duplicate triggers (consolidate flow triggers)
Performance Metrics
Acceptable Performance:
< 100 flow triggers total
< 10 triggers per high-volume table
80% scenario success rate (< 20% skipped due to scenarios)
< 5% HTTP errors
Average response time < 3 seconds
Performance Issues Indicated By:
Slow user interface when posting documents
Users reporting delays
High CPU usage on BC server during posting
Many timeout errors in validation log
Validation log filling rapidly with skipped entries
💡 TIP: Use BC telemetry and performance monitoring to track rule engine impact. If performance issues arise, start by disabling flow triggers on the highest-volume tables and measure the improvement.
Load Testing
Before deploying many flow triggers to production, test with realistic load:
Test Procedure:1. Identify High-Volume Events
Which tables have most activity?
How many events per hour/day?
Peak times?
2. Create Test Data
Generate representative test records
Simulate peak load
3. Enable Flow Triggers
Configure all planned triggers
Point to test Power Automate flows (not production)
4. Simulate Load
Post multiple documents rapidly
Modify many records concurrently
Use multiple users if possible
5. Measure Impact
Record posting time before/after flow triggers
Monitor BC server CPU and memory
Check validation log for errors
Review Power Automate throttling limits
6. Optimize
Refine Trigger Strings
Combine flow triggers
Remove unnecessary triggers
Adjust scenarios
7. Repeat
Test again after optimization
Verify acceptable performance
Acceptable overhead: < 10% increase in transaction processing time.
This completes Chapter 4. You now understand triggers, scenarios, rule groups, complex conditional logic, and performance optimization techniques.
