This document describes the PX1056 diagnostic.
Code | Short Description | Type | Code Fix |
---|---|---|---|
PX1056 | A PXGraph instance cannot be initialized inside the IsActive or IsActiveForGraph<TGraph> method. |
Error | Unavailable |
You cannot create a graph instance in the IsActive
method of a graph or DAC extension or in the IsActiveForGraph<TGraph>
method of a graph extension because this creation can lead to a deadlock.
Instead, to access a graph member, you can use database slots. For details, see the Restrictions in the IsActive Method section
of the To Enable a Graph Extension Conditionally (IsActive) article.
public static bool IsActive()
{
var invoiceEntry = PXGraph.CreateInstance<SOInvoiceEntry>();
return (bool)invoiceEntry.sosetup.Current.InspectionEnabled;
}
private class SOSetupInspection : IPrefetchable
{
public static bool InspectionEnabled =>
PXDatabase.GetSlot<SOSetupInspection>("SOSetupInspection", typeof(SOSetup))._inspectionEnabled;
private bool _inspectionEnabled;
void IPrefetchable.Prefetch()
{
using (PXDataRecord soSetup =
PXDatabase.SelectSingle<SOSetup>(new PXDataField<SOSetup.inspectionEnabled>()))
if (soSetup != null) _inspectionEnabled = (bool)soSetup.GetBoolean(0);
}
}
public static bool IsActive() => SOSetupInspection.InspectionEnabled;