bcquality/microsoft/knowledge/performance/al-methods-limited-during-write-transactions.good.al
Michael Dieringer 1e5d901bd4 Title the article after the platform error it explains
"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>
2026-09-21 21:56:30 +02:00

18 lines
715 B
AL

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;
}