【问题标题】:InventoryID on child record not updating when saving new item保存新项目时子记录上的 InventoryID 未更新
【发布时间】: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


【解决方案1】:

是的,您需要包含 PXDBDefault 属性。为确保起见,您可以将 DefaultForInsert 属性指定为 true 或在图形初始化时通过 PXDBDefaultAttribute.SetDefaultForInsert 设置此属性(请参阅https://help-2021r1.acumatica.com/(W(5))/Help?ScreenId=ShowWiki&pageid=680e01c8-6b98-74bb-ef73-b605e37c33f5

【讨论】:

  • 感谢您的回答。我尝试在 CacheAttached 事件上使用 PXDBDefault 属性,但这不起作用。我会用这些信息更新我的问题。我还尝试了使用和不使用 DefaultForInsert 和 DefaultForUpdate 以及 PXDefault。我不确定为什么不使用 InventoryItem 中的 inventoryID 更新 ARSAlesPrice 上的 inventoryID...
猜你喜欢
  • 2013-01-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多