AL methods limited during write transactions (RunModal, Codeunit.Run) - #161
Open
Michael Dieringer (MichaelDieringer) wants to merge 6 commits into
Conversation
… page" from the prompts article A modal page does not behave like Confirm/StrMenu inside a write transaction: the platform refuses Page.RunModal (and Report/XmlPort .RunModal with a request page, and Codeunit.Run with its return value used) with a runtime error instead of holding the lock. The new article documents that guard - verified against Microsoft Learn (Codeunit.Run transaction semantics), microsoft/AL#5452, Microsoft's own Base Application (Commit(); Page.RunModal pattern), and a live reproduction on Business Central 26 quoted verbatim. avoid-user-prompts-inside- transactions.md keeps its scope to the prompts the platform does allow; "modal page" is removed from its list because that case is refused, not stalled. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Message runs asynchronously - it is queued and shown when the calling method ends or another method requests input - so it never pauses the transaction and holds no lock. Only Confirm and StrMenu wait for the user. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…method Mirrors the structure of the platform's own error message so the Report.RunModal and XmlPort.RunModal request-page exceptions are visible at a glance instead of buried in prose. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
"AL methods limited during write transactions: commit before RunModal and Codeunit.Run" - so a developer or agent searching for the runtime error text lands on the one article that covers all four restricted methods. Slug and sample stems renamed to match; keywords gain the error's own phrase and the legacy Form.RunModal name it still uses. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Adds Page.RunModal / Report.RunModal / XmlPort.RunModal / UseRequestPage to the extracted-token list and one deterministic worklist cue with exclusions, so the article is selected from the RunModal call itself rather than only via a co-located Commit/Modify token. Codeunit.Run in that position is routed to its existing owner article. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Author
|
@microsoft-github-policy-service agree company="CURABIS ApS" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
One new
performancearticle,al-methods-limited-during-write-transactions.md, documenting the platform restriction behind the runtime error "The following AL methods are limited during write transactions because one or more tables will be locked: Form.RunModal, Codeunit.Run, Report.RunModal, XmlPort.RunModal." — one explicit line per method with its exact condition (Page.RunModal never; Report/XmlPort.RunModal only with the request page suppressed; Codeunit.Run only when the return value is unused), why the guard exists, and how to structure code so it never triggers.Why the Microsoft layer: this is platform-enforced behavior, not a team convention. Verified against: Microsoft Learn (
Codeunit.Runtransaction semantics — "you must commit first"); a live reproduction on Business Central 26 (2026-09-07,Item.Insert()thenPage.RunModal(Page::"Customer Card")— unrelated table — fails on the RunModal line; message quoted verbatim); Microsoft's own Base Application, which follows theCommit(); Page.RunModal(...)pattern inActivityLog.Table.al,DocumentSendingProfile.Table.al,PaymentServiceSetup.Table.aland others; and microsoft/AL#5452 for the pre-2019 wording. Only the Codeunit.Run leg is documented on Learn; the RunModal legs exist only as the runtime error text — which is exactly why an agent gets this wrong without the file.Relationship to existing articles:
codeunit-run-requires-prior-commit-inside-transaction.mdkeeps ownership of the Codeunit.Run leg (cross-referenced, not duplicated).avoid-user-prompts-inside-transactions.mdkeeps the prompts the platform allows inside a write transaction (Confirm/StrMenu — which therefore silently hold locks); the two words "modal page" are removed from its list, because that case is refused with a runtime error, not stalled.Wiring:
al-performance-review.mdgainsPage.RunModal/Report.RunModal/XmlPort.RunModal/UseRequestPagetokens and one deterministic worklist cue with exclusions (RunModal before every write; request page suppressed), routing Codeunit.Run in that position to its existing owner — per #155's coverage contract.Samples reference real objects only: page 428 "Shipping Agents", table 291 "Shipping Agent" (
Code[10]), Sales Header fields 21 "Shipment Date" and 105 "Shipping Agent Code".Test plan
validate_frontmatter.py --root .— 0 errors, 0 warningsBuild-KnowledgeIndex.ps1— 301 articles, deterministicTest-ReviewFixtures.ps1— 34 cases / 17 leaf domainscompany="CURABIS ApS")microsoft/knowledge/performance/)