This document describes the PX1059 diagnostic.
Code | Short Description | Type | Code Fix |
---|---|---|---|
PX1059 | Changes to PXCache cannot be performed during the PXGraph initialization. |
Error | Unavailable |
Changes to PXCache
cannot be performed during the PXGraph
initialization (that is, in PXGraph
constructors, in the Initialize
method overridden in PXGraphExtension
, or in handlers subscribed at run time through the static InstanceCreated
member of PXGraph
).
The diagnostic finds invocations of the following methods:
- The
Insert
,Update
, andDelete
methods of thePXCache
object - The
Insert
,Update
, andDelete
methods of decendants of thePXSelectBase<>
class
The invocation of these methods during the PXGraph
initialization can lead to data inconsistency.
During the PXGraph
initialization, you can configure basic UI presentation logic and can make sure that all necessary configuration data for the screen is available. No other business logic should be executed during the PXGraph
initialization.
To prevent the error from occurring, you should remove from the PXGraph
initialization the code that changes PXCache
and rework the related business logic.
public class SOOrderEntry : PXGraph<SOOrderEntry>
{
public SOOrderEntry()
{
var doc = Orders.Current;
doc.OrderType = "SO";
Orders.Cache.Update(doc); //The PX1059 error is displayed for this line.
}
}