Platform API: Improvements to the PK.Find Method
In MYOB Acumatica 2024.1, a new optional parameter, options, has been introduced in the PK.Find method. By using this parameter, developers can specify whether the Dirty cache can be used, as well as whether the global cache should be used..
Use of the Dirty Cache
In previous versions of MYOB Acumatica, a developer could not put the record returned by the PK.Find method in the cache including the Current property of the cache; the developer also could not change the returned record. Now a developer can specify whether the Dirty cache should be used, which gives the developer the ability to utilize the record returned by the PK.Find method in any place, including the cache.
To specify that the records marked as Dirty in the cache (that is, updated, inserted, or deleted in the cache) should be included in the query result, the developer should specify the PKFindOptions.IncludeDirty flag when calling the Find method. An example is shown in the following code.
shipmentEntry.Document.Current = SOShipment.PK.Find(shipmentEntry,
doc.ShipmentNbr,
PKFindOptions.IncludeDirty);