This document describes the PX1047 diagnostic.
Code | Short Description | Type | Code Fix |
---|---|---|---|
PX1047 | In the FieldDefaulting , FieldVerifying , and RowSelected event handlers, DAC instances passed to these event handlers cannot be modified. |
Error | Unavailable |
In the FieldDefaulting
, FieldVerifying
, and RowSelected
event handlers, values cannot be specified for the fields of the DACs passed to these event handlers. In the FieldDefaulting
event handler, you can change only the value of e.NewValue
. The FieldVerifying
and RowSelected
event handlers are not designed for the modification of data records. If the DAC field values have been changed in these event handlers, these values can be changed unexpectedly because of the execution of subsequent event handlers.
To prevent the error from occurring, you should remove from the event handler the code that assigns a value to a DAC field and rework the related business logic. You can move the code to the FieldUpdated
or RowUpdated
event handler.
This diagnostic is displayed as a warning if the Enable additional diagnostics for ISV Solution Certification option (in Tools > Options > Acuminator > Code Analysis) is set to False
.
protected virtual void APInvoice_DueDate_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
{
APInvoice invoice = (APInvoice)e.Row;
if (invoice.DocType == APDocType.Prepayment)
{
invoice.DueDate = invoice.DocDate; // The PX1047 error is displayed for this line.
}
}