mirror of
https://github.com/microsoft/BCQuality.git
synced 2026-10-05 14:46:55 +01:00
"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>
18 lines
706 B
AL
18 lines
706 B
AL
codeunit 50258 "Perf Sample RunModalInTxn Bad"
|
|
{
|
|
procedure ChangeShippingAgent(DocNo: Code[20])
|
|
var
|
|
SalesHeader: Record "Sales Header";
|
|
ShippingAgent: Record "Shipping Agent";
|
|
begin
|
|
SalesHeader.Get(SalesHeader."Document Type"::Order, DocNo);
|
|
SalesHeader."Shipment Date" := WorkDate();
|
|
SalesHeader.Modify(true); // a write transaction is now open
|
|
|
|
// Runtime error: RunModal is not allowed in write transactions.
|
|
if Page.RunModal(Page::"Shipping Agents", ShippingAgent) = Action::LookupOK then begin
|
|
SalesHeader.Validate("Shipping Agent Code", ShippingAgent.Code);
|
|
SalesHeader.Modify(true);
|
|
end;
|
|
end;
|
|
}
|