【发布时间】:2022-01-27 21:08:44
【问题描述】:
我在 InventoryItemMaintBase 图表上有 ARSalesPrice 记录,其中包含一些附加功能。当在尚未保存的新商品上输入这些销售价格时,我收到错误消息:
Cannot insert the value NULL into column 'InventoryID', table 'AC2021R1.dbo.ARSalesPrice';
column does not allow nulls. INSERT fails.
The statement has been terminated.
似乎在分配库存 ID 时,它并没有转移到 ARSalesPrice。 ARSalesPrice DAC 上的库存 ID 字段具有 InventoryItem 的 PXParent 以及 CacheAttached 事件的 PXDBDefault 属性。我的印象是,这就是我所需要的。您知道我应该怎么做才能在第一次保存 ARSalesPrice 时将库存 ID 分配给它吗?
缓存附加:
[PXMergeAttributes(Method = MergeMethod.Merge)]
[PXParent(typeof(Select<InventoryItem, Where<InventoryItem.inventoryID, Equal<Current<ARSalesPrice.inventoryID>>>>))]
[PXDBDefault(typeof(InventoryItem.inventoryID), DefaultForInsert = true, DefaultForUpdate = true)]
protected virtual void _(Events.CacheAttached<ARSalesPrice.inventoryID> e)
{
}
感谢您的帮助!
【问题讨论】:
-
不确定是不是这样,但您是否还在 ARSalesPrice 上包含了 PXDBDefault 以从 InventoryItem 填充 InventoryID?你不能只定义一个父母。你必须做一些事情来填充它。由于您需要它基于父 DAC,因此您将使用 PXDBDefault 而不是 PXDefault。
标签: acumatica