Skip to content

Latest commit

 

History

History
59 lines (44 loc) · 2.69 KB

PX1070.md

File metadata and controls

59 lines (44 loc) · 2.69 KB

PX1070

This document describes the PX1070 diagnostic.

Summary

Code Short Description Type Code Fix
PX1070 The state of fields and actions can be configured only in RowSelected event handlers. Error Unavailable

Diagnostic Description

The only event handler where the UI presentation logic can be implemented is the RowSelected event handler. Implementation of the UI presentation logic in most of the other event handlers has no effect on the UI.

This rule applies to the configuration of PXFieldState that is performed with the following methods:

  • The static SetVisible, SetEnabled, SetRequired, SetDisplayName, SetReadOnly, SetVisibility, and SetNeutralDisplayName methods of PXUIFieldAttribute
  • The SetList, AppendList, and SetLocalizable methods of PXStringListAttribute and PXIntListAttribute
  • The SetEnabled, SetVisible, SetCaption, and SetTooltip methods of PXAction

The common UI presentation logic, which doesn't depend on particular values of the data record, can also be implemented in the constructor of the graph.

To prevent the error from occurring, you can move the code that changes the state of the field or action to the RowSelected event handler or to the graph constructor.

Example of Incorrect Code

public class SOOrderEntry : PXGraph<SOOrderEntry, SOOrder>
{
    public PXAction<SOOrder> Release;

    protected virtual void SOOrder_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
    {
        var row = e.Row as SOOrder;
        Release.SetVisible(row?.Hold != true); //The PX1070 error is displayed for this line.
        PXUIFieldAttribute.SetEnabled<SOOrder.Hold>(sender, true); //Another PX1070 error is displayed for this line.
    }
}

Example of Possible Code Fix

public class SOOrderEntry : PXGraph<SOOrderEntry, SOOrder>
{
    public PXAction<SOOrder> Release;

    protected virtual void SOOrder_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
    {
        var row = e.Row as SOOrder;
        Release.SetVisible(row?.Hold != true);
        PXUIFieldAttribute.SetEnabled<SOOrder.Hold>(sender, true);
    }
}

Related Articles