videoAL Developmentcommunity - not Microsoftreviewed - checked by Opus

20261026 - The Rollback That Wasn’t Transaction & Error Handling

AL transaction and error handling in Business Central: what rollback does and does not undo, why try functions do not undo writes online, how Commit and the CommitBehavior attribute work, and how to test and review transaction code. Includes patterns for external integration and batch processing.

  1. 0:00 Introduction and Housekeeping
  2. 4:00 Speaker Introduction and Session Overview
  3. 5:47 Transaction Basics and ACID Properties
  4. 7:32 Why Transaction Atomicity Matters
  5. 9:15 Transaction Ownership and Commit Behavior
  6. 10:42 What Rollback Actually Undoes and Posting Preview
  7. 12:29 The Rollback That Wasn't - First Bug Pattern
  8. 14:53 Ways to Prevent Rollback in Try Functions
  9. 15:55 The Rollback You Didn't Want - Error Handling Patterns
  10. 17:12 The Rollback That Can't Happen - External System Integration
  11. 18:50 Transaction Control Tools and Commit Fundamentals
  12. 20:53 Commit Anti-Patterns and Batch Checkpointing
  13. 23:07 CommitBehavior Attribute and Integration Events
  14. 25:06 CommitBehavior Rules and Scope
  15. 27:54 Commit Behavior Applications: ignore vs error
  16. 29:35 Scoped Undo Button: Error-scoped Code Units
  17. 31:42 Code Unit Transactions: Common Mistakes
  18. 34:50 Wrong Fixes and the Right Approach
  19. 36:13 Try Functions: When to Use and Not Use
  20. 37:59 Fixing Try Function Anti-patterns
  21. 40:04 Test Transaction Models
  22. 40:59 Testing rollback and transaction scenarios
  23. 42:32 Error info data type and fix-it actions
  24. 45:13 Collectible errors and error behavior collect
  25. 48:03 Real-world examples: parallel worker and batch processing
  26. 50:48 Decision map for transaction patterns
  27. 52:40 Code review checklist for transactions and errors
  28. 53:49 Key Principles and Best Practices Summary
  29. 54:43 Q&A: Commit Behavior and Default Settings
  30. 56:35 Q&A: Try-Catch Behavior in Cloud vs On-Premise
  31. 57:34 Presentation Availability and Technical Discussion
  32. 58:24 Closing Remarks and Upcoming Events
video Areopa webinars · 2026-10-27Watch on YouTube

Overview

The session explains how the AL runtime manages database transactions. A write transaction starts on the first insert, modify or delete and commits when code ends without error. Rollback undoes only writes to normal tables since the last commit. Variables, temporary records, single instance codeunit state, HTTP calls, emails and telemetry are not undone. The speaker uses this to explain posting preview, which relies on temporary data surviving an intentional rollback.

The talk then covers the common failure patterns and the tools to avoid them. Try functions catch errors but do not undo writes; online allows writes in try methods, while on-premises blocks them by default. Explicit commits make earlier work final. CommitBehavior can ignore or error on commits in called code. Error-scoped codeunits used with a return value act as a scoped undo. The talk also covers test transaction models, ErrorInfo with fix-it actions, collectible errors, an outbox pattern for external systems, a batch checkpoint pattern, and an eight-item code review checklist.

Key points

  • Rollback undoes inserts, modifies and deletes on normal tables since the last commit. It does not undo variables, temporary records, single instance codeunit state, HTTP calls, sent emails or telemetry.
  • Posting preview uses this on purpose: it posts into real tables while subscribers copy entries into temporary tables, then raises an intentional error caught by if Codeunit.Run. The real posting rolls back but the temporary copies survive.
  • A try function catches the error but does not undo writes made inside it. Online allows writes in try methods; on-premises blocks them by default (an NST setting that can be changed on-premises but not online). The documentation says this behavior might change in an upcoming release.
  • A try function only forms a boundary when its return value is used. A bare call is an ordinary call and the error propagates.
  • Commit makes everything since the last commit final, including callers’ and subscribers’ writes. Each commit should have a comment saying why, and the state after it must be recoverable.
  • CommitBehavior on a procedure or event can ignore commits or raise an error on them. The stricter rule wins in parent-child combinations, and the attribute cannot be conditional. In BC 29, Sales-Post runs line posting under CommitBehavior Ignore by default, and posting preview uses Error.
  • Running a codeunit with its Boolean return value (if Codeunit.Run) works as a scoped undo, but only from a clean state. Commit first if a write transaction is open; the runtime enforces this, the compiler does not.

Features

Feature Status At Evidence
Transaction control in AL runtime status not stated 6:37
Rollback scope limitations status not stated 10:42
Explicit commit splitting transactions status not stated 9:59
The rollback that wasn’t - try-catch with database writes status not stated, demoed 13:20
Try function error handling status not stated, demoed 13:10
Commit method behavior status not stated, demoed 19:41
Outbox pattern for external integration status not stated 17:26
Idempotent request IDs status not stated 17:57
External Business Events post-commit behavior status not stated 18:23
Batch checkpoint pattern status not stated, demoed 22:07
Commit Behavior function attribute generally available, demoed 26:31 “Microsoft ships this in base app. Sales post runs the posting lines under commit behavior ignore by default, at least in BC 29.” (27:54)
Error-scoped Code Units for clean state transactions status not stated, demoed 29:35
Try function attribute with return value status not stated, demoed 36:13
Test transaction models status not stated 40:04
Test transaction model - after rollback status not stated, demoed 40:15
Test transaction model - after commit status not stated, demoed 40:37
Test transaction model - none status not stated, demoed 40:48
Error info data type status not stated, demoed 42:32
Fix-it actions in error dialog status not stated, demoed 42:32
Error behavior collect status not stated, demoed 45:13
Collectible errors in error info status not stated, demoed 45:50
Free show-it feature since BC 24 status not stated, demoed 44:53
Transaction Handling Checklist status not stated 52:07
Try Function Behavior: On-Premise vs Online status not stated 56:35

AL objects mentioned

As heard in the captions. A name that matches one object page by exact type and name links to it; the others stay as named.

  • codeunit “Parallel Worker” at 5:35
  • codeunit “Sales post” at 27:54
  • codeunit “codeunit.run” at 56:20

Not found in BC28-30: codeunit “Parallel Worker”, codeunit “Sales post”, codeunit “codeunit.run”.

Quotes

  • 5:47 “What is a transaction itself? Well, a transaction is a group of database changes that succeed together or fail together.”
  • 6:37 “In AL, the runtime does it for you. When AL code needs a transaction, the runtime starts one. And when the code finishes, the”
  • 10:42 “It’s undoes inserts, modifies, and deletes on normal tables since the last commit. But, not undone. Your variables, temporary records, single instance could you”
  • 11:38 “Posting preview. So, let’s imagine we have general uh posting preview could you need which really post into real tables data.”
  • 14:00 “The error was caught, but the right inside the try function wasn’t undone. That’s how it works online.”

Disclaimers in the video

  • 4:56 other: Microsoft MVP since 2025
  • 14:14 other: On premises, the seller blocks any rights inside try methods by default.
  • 37:15 subject-to-change: the documentation says this behavior might change in upcoming release
  • 55:28 other: I think it will be bad because it’s not how publisher works by default

Presenters (as heard): Luke, Volodymyr Vernitsky, Vlado.