Skip to content

Latest commit

 

History

History
38 lines (28 loc) · 2.2 KB

PX1049.md

File metadata and controls

38 lines (28 loc) · 2.2 KB

PX1049

This document describes the PX1049 diagnostic.

Summary

Code Short Description Type Code Fix
PX1049 In RowSelected event handlers, BQL statements and other database queries should be avoided. Warning (ISV Level 1: Significant) Unavailable

Diagnostic Description

BQL statements and other database queries (such as PXDatabase.Select) should be avoided in RowSelected event handlers. Because of multiple invocations of the RowSelected event for a single data record, the execution of database queries in RowSelected event handlers can cause performance degradation.

Database queries can be executed in RowSelected event handlers in specific scenarios, such as if you need to make the Delete button unavailable for a record if the record has detail lines. In these scenarios, the database queries should select no more than one record from the database.

To prevent the warning from occurring, you should remove the BQL statement or the database query from the RowSelected event handler.

This diagnostic is displayed only if the Enable additional diagnostics for ISV Solution Certification option (in Tools > Options > Acuminator > Code Analysis) is set to True.

Example of Code that Results in the Warning

protected virtual void SOOrder_RowSelected(PXCache sender, PXRowSelectedEventArgs e, PXRowSelected InvokeBaseHandler)
{
    if (InvokeBaseHandler != null)
        InvokeBaseHandler(sender, e);
    if (e.Row != null)
    {
        var ord = PXSelect<SOOrder, // The PX1049 warning is displayed for this line.
            Where<SOOrder.orderNbr, Equal<Required<SOOrder.orderNbr>>>>
            .Select(this, (e.Row as SOOrder).OrderNbr);
    }
}

Related Articles