How to automatically create Note record in Acumatica?

帅比萌擦擦* 提交于 2019-12-07 15:57:25

To have Note record automatically created when a new parent record gets saved, one should invoke the static PXNoteAttribute.GetNoteID<Field>(PXCache cache, object data) method when the parent record is inserted in the cache.

For example, to have Note record automatically created when a new Stock Item gets saved, you should subscribe to RowInserted handler for the InventoryItem DAC and call PXNoteAttribute.GetNoteID<Field>(...):

public class InventoryItemMaintExt : PXGraphExtension<InventoryItemMaint>
{
    public void InventoryItem_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
    {
        var noteCache = Base.Caches[typeof(Note)];
        var oldDirty = noteCache.IsDirty;
        PXNoteAttribute.GetNoteID<InventoryItem.noteID>(sender, e.Row);
        noteCache.IsDirty = oldDirty;
    }
}

The code snippet above can be incorporated into almost any custom BLC with a couple simple changes to replace InventoryItem with a custom DAC.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!