This document describes the PX1070 diagnostic.
Code | Short Description | Type | Code Fix |
---|---|---|---|
PX1070 | The state of fields and actions can be configured only in RowSelected event handlers. |
Error | Unavailable |
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
, andSetNeutralDisplayName
methods ofPXUIFieldAttribute
- The
SetList
,AppendList
, andSetLocalizable
methods ofPXStringListAttribute
andPXIntListAttribute
- The
SetEnabled
,SetVisible
,SetCaption
, andSetTooltip
methods ofPXAction
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.
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.
}
}
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);
}
}