acumatica - 保存记录时插入网格线
问题描述
我正在尝试在持久逻辑期间将新记录添加到网格中。但是,即使记录确实添加到 UI 中的网格中,当页面刷新时,新行也会消失。它没有在数据库中持久化。
我使用账单页面作为参考。
代码示例
protected virtual void APTran_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
{
if (e.Row == null)
{
return;
}
APInvoice invoiceRow = this.Base.Document.Current;
if (invoiceRow != null)
{
APTran tranRow = new APTran();
tranRow = this.Base.Transactions.Insert(tranRow);
tranRow.InventoryID = 10043;
this.Base.Transactions.Update(tranRow);
tranRow.Qty = 3;
this.Base.Transactions.Update(tranRow);
}
}
解决方案
像这样的事情,我倾向于在调用 base persist 之前覆盖 Persist 方法并插入或更新相关记录。这是一个可能的示例,它包含在您的图形扩展中:
[PXOverride]
public virtual void Persist(Action del)
{
foreach(APInvoice invoiceRow in Base.Document.Cache.Inserted)
{
APTran tranRow = this.Base.Transactions.Insert();
tranRow.InventoryID = 10043;
tranRow = this.Base.Transactions.Update(tranRow);
tranRow.Qty = 3;
this.Base.Transactions.Update(tranRow);
}
del?.Invoke();
}
推荐阅读
- python - 如何将 tf.estimator.predict 用于单个数据项
- java - 正则表达式匹配阿拉伯文本中的反括号
- python - 无法将容器中的 python 标准输出日志获取到“oc 日志”
- javascript - 无需额外的 ajax 请求即可将 laravel 数据转换为 vuex 状态?
- if-statement - 我应该将方法包装在 if 语句中还是将 if 语句放入方法本身?
- mysql - MySql 时差,意外行为
- python - 尝试使用 Python 发布请求时出现错误 405
- flutter - 如何使容器的填充可以点击?
- mysql - 在 mySQL 中从一个生成多行
- python-3.x - 如何将 s3 图像响应读取为对象