Commit requires a comment explaining why
The AL runtime automatically manages write transactions: it starts one when needed and commits when code execution completes. Calling Commit() manually interrupts this model by persisting changes before the platform normally would.
If you want the code execution to perform multiple write transactions, you must use the
Commitmethod to end one write transaction before you can start the next.
— Database.Commit() Method on Microsoft Learn
The reason for splitting a transaction cannot be inferred from the Commit() call alone. Without a comment, a future maintainer cannot tell whether the commit is an intentional design decision or an oversight from a refactor — and may break a dependent workflow by removing it, or perpetuate a pattern they do not understand.
Add a leading or trailing comment that explains why the commit is necessary.
Example
procedure PostAndCallExternalService()
begin
Rec.Modify(true);
Commit(); // Commit requires a comment explaining why [DC0001]
CallExternalWebService(Rec);
end;Add a comment explaining why the commit is necessary:
procedure PostAndCallExternalService()
begin
Rec.Modify(true);
// Commit required: the web service call that follows must not roll back the posted document
Commit();
CallExternalWebService(Rec);
end;See also
- Database.Commit() Method on Microsoft Learn