Acumatica 自定义字段 SOLine 转移到 ARTran [英] Acumatica custom field SOLine transferred to ARTran

查看:21
本文介绍了Acumatica 自定义字段 SOLine 转移到 ARTran的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将销售订单 (SOLine) 行上的自定义字段值传播到销售发票 (ARTran).我查看了其他示例,但无法使代码正常工作...见下文:

I'm trying to propogate a custom field value on the line of a sales order (SOLine) to the sales invoice (ARTran). I've looked at other examples but can't get the code to work...see below:

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

}


}

推荐答案

您想将处理程序放在创建 ARTran、ARInvoiceEntry 的图形上:

You want to put the handler on the graph which creates the ARTran, ARInvoiceEntry:

PXGraph.InstanceCreated.AddHandler<ARInvoiceEntry>((graph) =>
{
    graph.RowInserting.AddHandler<ARTran>((sender, e) =>
    {
    }
}

您设置的方式将捕获 SOInvoiceEntry 图上的事件,该图不是插入 ARTran 行的事件,ARInvoiceEntry 是插入行的事件.

The way you have it setup it will catch the event on the SOInvoiceEntry graph which is not the one inserting the ARTran lines, ARInvoiceEntry is the one insterting the lines.

InvoiceCreated 可能不是放置它的正确位置.通常我会在调用 CreateInvoice Action 之前放置事件钩子.

InvoiceCreated is probably not the right place to put it though. Usually I put the event hook right before calling the CreateInvoice Action.

顺序是:

  1. 使用 InstanceCreated,您可以将钩子添加到将被实例化的任何泛型类型 T 的图形中.在您的情况下,类型是 ARInvoiceEntry

  1. With InstanceCreated you add the hook to any graph of generic type T that will be instantiated. In your case type is ARInvoiceEntry

调用 CreateInvoice 操作.

Call CreateInvoice Action.

这篇关于Acumatica 自定义字段 SOLine 转移到 ARTran的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆