Hello all,
I have the below code that works just fine and as expected in 2022R2. I am upgrading this package to 2023R2 and I am getting an error that “Cannot mark the record as updated because another record with the same key exists in the cache. Contact your Acumatica support provider for the assistance.” When I trace on the line that I try “journalGraph.Save.Press();” the problem is caused.
Any idea what is going on or has someone come across the similar issues on upgrade to 2023R2? This is my code without any change from 2022R2 => 2023R2.
#region Reverse Action & Method
public PXAction<HCLPMWIP> HCLreverse;
[PXUIField(DisplayName = HCLPMMessages.Reverse, MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
[PXButton]
public IEnumerable HCLReverse(PXAdapter adapter)
{
if (IsValidWIPDocument() == true)
{
try
{
JournalEntry journalGraph = PXGraph.CreateInstance<JournalEntry>();
journalGraph.BatchModule.Current = Batch.PK.Find(this, BatchModule.GL, HCLWIPDocument.Current.BatchNbr);
if (journalGraph.BatchModule.Current != null)
{
if (journalGraph.BatchModule.Current.Released != true)
{
journalGraph.BatchModule.Delete(journalGraph.BatchModule.Current);
journalGraph.Save.Press();
}
else
{
throw new PXException(HCLPMMessages.GLBatchIsReleased);
}
}
HCLWIPDocument.Current.Status = HCLPMWIPStatus.OnHold;
HCLWIPDocument.Current.Released = false;
HCLWIPDocument.Current.Module = null;
HCLWIPDocument.Current.RefNbr = null;
HCLWIPDocument.Current.BatchNbr = null;
}
finally
{
HCLWIPDocument.Update(HCLWIPDocument.Current);
Save.Press();
}
}
return adapter.Get();
}
#endregion