Warm tip: This article is reproduced from stackoverflow.com, please click
acumatica crud

Determine if a record has been updated/inserted/deleted

发布于 2020-03-27 10:16:14

I have a DAC called APTran. I want to make sure all my records within this DAC have been inserted.

this is to audit my APTran records against a corresponding POReceiptLine unbilled qty

foreach(APTran apTran in Base.Transactions.Select())
{
   // determine the state of apTran (inserted, Deleted)
}
Questioner
Adam St.Hilaire
Viewed
41
Hugues Beauséjour 2019-07-03 22:01
bool isInserted = cache.GetStatus(apTran) == PXEntryStatus.Inserted;
bool isDeleted = cache.GetStatus(apTran) == PXEntryStatus.Deleted;
bool isInsertedDeleted = cache.GetStatus(apTran) == PXEntryStatus.InsertedDeleted;

InsertedDeleted is a special case where the record was inserted in the cache but deleted before it got persisted to database.

I don't know of an official way to check if records were actually inserted in database. What I usually do is check one of the database generated fields value. They will be null until inserted in the database.

bool hasBeenPersisted = apTran.Tstamp != null;