Skip to content

Latest commit

 

History

History
50 lines (38 loc) · 2.12 KB

PX1042.md

File metadata and controls

50 lines (38 loc) · 2.12 KB

PX1042

This document describes the PX1042 diagnostic.

Summary

Code Short Description Type Code Fix
PX1042 In a RowSelecting handler, BQL statements and other database queries must be executed only inside a separate connection scope. For Acumatica ERP 2023 R1 and later versions, this diagnostic is disabled. Error Available

Diagnostic Description

In a RowSelecting handler, BQL statements and other database queries (such as PXDatabase.Select) must be executed only inside a separate connection scope.

The use of a separate connection scope is required to execute additional BQL statements in the RowSelecting event handler, because the current connection scope used to retrieve data is still busy at the moment. Thus no other operations on this connection scope are allowed.

Starting with Acumatica ERP 2023 R1, the Acumatica runtime was changed to allow DB queries execution in the RowSelecting event handler without a separate connection scope. Therefore, for Acumatica ERP 2023 R1, this diagnostic is disabled.

The code fix surrounds the BQL statement or the database query execution with a connection scope.

Example of Incorrect Code

public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
    protected virtual void _(Events.RowSelecting<SOOrder> e)
    {
	    var setup = PXSelect<SOSetup>.SelectSingleBound(Base, null); // The PX1042 error is displayed for this line.
    }
}

Example of Code Fix

public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
    protected virtual void _(Events.RowSelecting<SOOrder> e)
    {
        using (new PXConnectionScope())
        {
	        var setup = PXSelect<SOSetup>.SelectSingleBound(Base, null);
        }
    }
}

Related Articles

RowSelecting