Skip to main content
Solved

Issue After Upgrade to 2024 R1: Aggregate Validation Error on POLine+baseReceivedQty

  • December 26, 2024
  • 1 reply
  • 125 views

DipakNilkanth
Pro III
Forum|alt.badge.img+13

Hi Experts,

I am upgrading a customization to Acumatica 2024 R1. The same customization code worked perfectly in the previous version, but after the upgrade, I am encountering the following error when trying to save:

A data corruption state has been detected. You cannot save the changes. Copy the data you have entered and reload the page. Date and Time: 2024-12-26T12:39:04; IncidentID: 01ee5a5c-d4d4-43e4-86dd-7a4225f40541; Name: Aggregate Validation: PX.Objects.PO.POLine+baseReceivedQty. You can view detailed information about the issue on the System Events tab of the System Monitor (SM201530) form.
Here is the relevant customization code on POReceiptEntry graph:



namespace PX.Objects.PO
{
// Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod extension should be constantly active
public class POReceiptEntry_Extension : PXGraphExtension<POReceiptEntry>
{
#region Event Handlers

protected void POReceiptLine_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e)
{

var row = (POReceiptLine)e.Row;
var oldrow = (POReceiptLine)e.OldRow;
if (row == null)
return;

POReceipt po = Base.Document.Current;
if (row.PONbr != null)
{
POOrder poOrder = PXSelect<POOrder, Where<POOrder.orderNbr, Equal<Required<POOrder.orderNbr>>>>.Select(Base, row.PONbr);

if (poOrder == null) return;

var paymentTerms = poOrder.TermsID;
if (string.IsNullOrEmpty(paymentTerms)) return; // Ensure paymentTerms is not null or empty


POReceiptLineExt receiptExt = PXCache<POReceiptLine>.GetExtension<POReceiptLineExt>(row);

//receiptExt.UsrPaymentTerm = paymentTerms;
cache.SetValueExt<POReceiptLineExt.usrPaymentTerm>(row, paymentTerms);
}
if (row!=null)
{
if (!cache.ObjectsEqual<POReceiptLine.tranCost>(row, oldrow))
{
decimal? amount = 0;
decimal? amountPurchase = 0;

List<string> ary = new List<string>();
if (po != null)
{
POReceiptExt ExtOpportunity = PXCache<POReceipt>.GetExtension<POReceiptExt>(po);
foreach (POReceiptLine ln in Base.transactions.Select())
{
POOrder ordpo = PXSelectReadonly<POOrder, Where<POOrder.orderType, Equal<Required<POOrder.orderType>>,
And<POOrder.orderNbr, Equal<Required<POOrder.orderNbr>>>>>.Select(Base, ln.POType, ln.PONbr);
if (ordpo != null && !(ary.Contains(ln.PONbr)))
{
// POReceiptExt ExtOpportunity1 = PXCache<POReceipt>.GetExtension<POReceiptExt>(po);
amountPurchase = amountPurchase + ordpo.CuryOrderTotal;

ary.Add(ln.PONbr);

}

if (ln.TranCost > 0)
{
amount = amount + ln.TranCost;

}
else
{
ExtOpportunity.UsrCuryTot = 0;
}

}
ExtOpportunity.UsrCuryTotPurchase = amountPurchase;
ExtOpportunity.UsrCuryTot = amount;
po = Base.Document.Update(po);
Base.transactions.View.RequestRefresh();

}
}
}

}

protected void POReceiptLine_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{

var row = (POReceiptLine)e.Row;
if (row == null)
return;
POReceiptLineExt ext = row.GetExtension<POReceiptLineExt>();
if (ext != null)
{
if (ext.UsrPaymentTerm != null)
{
PXUIFieldAttribute.SetEnabled<POReceiptLineExt.usrPaymentTerm>(cache, row, false);
}
}

}

protected void POReceipt_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{

var row = (POReceipt)e.Row;
if (row == null)
return;

PXUIFieldAttribute.SetEnabled<POReceipt.invoiceNbr>(cache,row, true);


}
protected void POReceiptLine_RowPersisted(PXCache cache, PXRowPersistedEventArgs e)
{

var row = (POReceiptLine)e.Row;
if (row == null) return;



POReceipt po = Base.Document.Current;
if (row.PONbr != null)
{
POOrder poOrder = PXSelect<POOrder, Where<POOrder.orderNbr, Equal<Required<POOrder.orderNbr>>>>.Select(Base, row.PONbr);

if (poOrder == null) return;

var paymentTerms = poOrder.TermsID;
if (string.IsNullOrEmpty(paymentTerms)) return; // Ensure paymentTerms is not null or empty


POReceiptLineExt receiptExt = PXCache<POReceiptLine>.GetExtension<POReceiptLineExt>(row);

// receiptExt.UsrPaymentTerm = paymentTerms;
cache.SetValueExt<POReceiptLineExt.usrPaymentTerm>(row, paymentTerms);
Base.transactions.Update(row);

}


}

protected void POReceiptLine_RowDeleted(PXCache cache, PXRowDeletedEventArgs e)
{
var row = (POReceiptLine)e.Row;
if (row == null)
return;
POReceipt po = Base.Document.Current;
decimal? amount = 0;
decimal? amountPurchase = 0;

List<string> ary = new List<string>();
POReceiptExt ExtOpportunity = PXCache<POReceipt>.GetExtension<POReceiptExt>(po);
foreach (POReceiptLine ln in Base.transactions.Select())
{
POOrder ordpo = PXSelectReadonly<POOrder, Where<POOrder.orderType, Equal<Required<POOrder.orderType>>,
And<POOrder.orderNbr, Equal<Required<POOrder.orderNbr>>>>>.Select(Base, ln.POType, ln.PONbr);
if (ordpo != null && !(ary.Contains(ln.PONbr)))
{
// POReceiptExt ExtOpportunity1 = PXCache<POReceipt>.GetExtension<POReceiptExt>(po);
amountPurchase = amountPurchase + ordpo.CuryOrderTotal;
ary.Add(ln.PONbr);

}

if (ln.TranCost > 0)
{
amount = amount + ln.TranCost;
}
else
{
ExtOpportunity.UsrCuryTot = 0;
}

}
ExtOpportunity.UsrCuryTotPurchase = amountPurchase;
ExtOpportunity.UsrCuryTot = amount;

}
}

#endregion
}

Thank you in advance for your guidance!

Best answer by DipakNilkanth

The issue is resolved by commenting the below code snippet 
Base.transactions.Update(row);
from Persisted event, now it is working fine and not giving any issue on saving the record.
Thanks!

1 reply

DipakNilkanth
Pro III
Forum|alt.badge.img+13
  • Author
  • Pro III
  • Answer
  • December 26, 2024

The issue is resolved by commenting the below code snippet 
Base.transactions.Update(row);
from Persisted event, now it is working fine and not giving any issue on saving the record.
Thanks!