我试图将销售订单(SOLine)行上的自定义字段值传播到销售发票(ARTran)。我查看了其他示例,但无法使代码生效......请参阅下文:
using PX.Objects.SO;
namespace PX.Objects.SO
{
public class SOInvoiceEntry_Extension:PXGraphExtension<SOInvoiceEntry>
{
#region Event Handlers
public delegate void InvoiceCreatedDelegate(ARInvoice invoice, SOOrder
source);
[PXOverride]
public void InvoiceCreated(ARInvoice invoice, SOOrder source,
InvoiceCreatedDelegate baseMethod)
{
baseMethod(invoice,source);
ARTran.RowInserted.AddHandler<ARTran>((cache, args) =>
{
var arTran = (ARTran)args.Row;
ARTranExt arTranExt = PXCache<ARTran>.GetExtension<ARTranExt>(arTran);
SOLineExt soLineExt = PXCache<SOLine>.GetExtension<SOLineExt>(soLine);
arTranExt.UsrContactID = soLineExt.UsrContactID;
});
}
#endregion
}
}
答案 0 :(得分:0)
您想将处理程序放在创建ARTran,ARInvoiceEntry的图表上:
PXGraph.InstanceCreated.AddHandler<ARInvoiceEntry>((graph) =>
{
graph.RowInserting.AddHandler<ARTran>((sender, e) =>
{
}
}
你设置它的方式将捕获SOInvoiceEntry图形上的事件,该图形不是插入ARTran线的图形,ARInvoiceEntry是一条线条。
InvoiceCreated可能不适合放置它。通常我在调用CreateInvoice Action之前将事件挂钩放在右边。
序列是:
使用InstanceCreated,您可以将钩子添加到将要实例化的泛型类型T的任何图形中。在您的情况下,类型是ARInvoiceEntry
调用CreateInvoice Action。