Usage of COMMIT in BC D365

Usage of COMMIT in BC D365:

(1) “COMMIT” is used mainly to end the write transaction in AL. It separates write transactions in AL. Actually COMMIT function tells the system that the first process has been completed and start the second process.

(2) Let’s take an example. Go to the “Sales-Post” Codeunit, as shown. There are many examples in the base object. If you read this code unit, you will find the use of the COMMIT function because multiple documents were created while posting Sales Shipment and Sales Invoice.

Commit example in D365 BC
BeginWriteTransactions
(C/AL Statements) // Transaction 1
COMMIT(…)
(C/AL Statements) // Transaction 2
EndWriteTransactions

(3) Note that the COMMIT function is used only when performing multiple transactions.

(4) Sometimes system will show an error as shown below, for that “COMMIT” function is mandatory for execution of AL code.

error in microsoft nav

(5) Suppose if you write COMMIT function after the first execution and if in second execution system will throw an error, then in that case system will not roll back the first execution.


Use of SETRANGE and SETFILTER in Dynamics 365
How to Fix WORK DATE issue in D365 BC
How to use FOR-TO loop statement in Microsoft D365
Database.Commit() Method– Microsoft Docs

Leave a Reply