mirror of
https://github.com/microsoft/BCQuality.git
synced 2026-10-06 23:26:55 +01:00
Add runmodal-is-not-allowed-inside-write-transactions.md; drop "modal 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>
This commit is contained in:
parent
07e324ddbc
commit
2a4cb856ef
4 changed files with 74 additions and 1 deletions
|
|
@ -0,0 +1,18 @@
|
|||
codeunit 50259 "Perf Sample RunModalInTxn Good"
|
||||
{
|
||||
procedure ChangeShippingAgent(DocNo: Code[20])
|
||||
var
|
||||
SalesHeader: Record "Sales Header";
|
||||
ShippingAgent: Record "Shipping Agent";
|
||||
begin
|
||||
// User interaction first, while no write transaction is open.
|
||||
if Page.RunModal(Page::"Shipping Agents", ShippingAgent) <> Action::LookupOK then
|
||||
exit;
|
||||
|
||||
// All writes after the choice is made; the transaction ends with the trigger.
|
||||
SalesHeader.Get(SalesHeader."Document Type"::Order, DocNo);
|
||||
SalesHeader."Shipment Date" := WorkDate();
|
||||
SalesHeader.Validate("Shipping Agent Code", ShippingAgent.Code);
|
||||
SalesHeader.Modify(true);
|
||||
end;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue