Fix for Invoice Posting Locks in Dynamics 365

Fix for Invoice Posting Locks in Dynamics 365 for Finance and Operations

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:

Disclaimer: The Questions and Answers provided on https://www.gigxp.com are for general information purposes only. We make no representations or warranties of any kind, express or implied, about the completeness, accuracy, reliability, suitability or availability with respect to the website or the information, products, services, or related graphics contained on the website for any purpose.
Avatar

Navneeth Nagrajan is a Technology Specialist at Deloitte Australia focussing on design, development, integration, and implementation of the Microsoft Power Platform (primarily PowerBI, Common Data Service and Flow) and Dynamics 365 for Finance and Operations ERP. Other areas of focus include Azure DevOps, Github (related to Dynamics 365 for Finance and Operations deployments), and Dynamics Lifecycle Services.Profile:Twitter: http://www.twitter.com/nav21n LinkedIn: https://www.linkedin.com/in/navneeth-nagrajan-94a9aa5/