One of the common issues that we face in a User Acceptance Testing (UAT) session is the database locks on invoice posting tables.
Issue:
When multiple users log in and are posting free text invoices or purchase invoices, the database was locking and preventing the invoices from being displayed.
Fix: (Invoice Posting Locks in Dynamics 365)
In General Ledger, there is a parameter under the section Source Document called Process source document lines in parallel. This should be set to ‘No’ instead of setting it to ‘Yes.’
How to check the invoice posting locking issues:
While posting a free text invoice, sales invoice or a purchase invoice, if the Dynamics 365 for Finance and Operations takes a while (ideally more than a minute to post an invoice), then choose the environment where we are monitoring the processing of invoices (i.e., UAT in this case) and choose SQL Insights -> Live View -> Currently Executing Statements.
In the Currently executing statements section, you will see a LCK_M_U wait typeset on the tables CustInvoiceInfoLine or CustInvoiceTable (if we are posting sales invoices) and/or on VendInvoiceTable or VendInvoiceInfoTable (if we are posting purchase invoices).
Fig 1 – Table locks in Lifecycle Services
Technical Reason:
The database locking for invoice posting tables usually occurs when the ‘Process source document lines in parallel’ is set to ‘Yes.’ This setting prevents the update of a specific field called SourceDocumentLine or SourceDocumentHeader on the line or header tables. This update fails when multiple users are logged into Finance and Operations and are trying to post Free Text Invoices or Sales Invoices or Purchase Invoices.
Details of the database fields are given below.
Free Text Invoice/Sales Invoice:
- Every time multiple users are posting purchase orders (existing or newly created) there is a field called the SourceDocumentLine that’s updated on the CustInvoiceLine table or the SourceDocumentHeader that’s updated on the CustInvoiceTable.
- The field will not update when the General Ledger parameter ‘Process source document lines in parallel’ is set to ‘Yes’ (as happened in this case initially).
Purchase Invoices:
- Every time multiple users are posting purchase invoices (existing or newly created) there is a field called the SourceDocumentLine that’s updated on the VendInvoiceInfoLine or the SourceDocumentHeader on the VendInvoiceInfoTable.
- The field will not update when the above mentioned General Ledger parameter ‘Process source document lines in parallel’ is set to ‘Yes.’
Fig 2 – Process source document lines in parallel
References:
- Microsoft Dynamics Lifecycle Services Engineering Blog
https://blogs.msdn.microsoft.com/lcs/ - General Ledger and Financial Reporting
https://docs.microsoft.com/en-us/dynamics365/unified-operations/financials/general-ledger/general-ledger