首页 > 解决方案 > APReleaseProcess_Extension 自定义代码在 Acumatica ERP 版本 2017 R2 中不起作用

问题描述

我尝试在“发布 AP 文档”屏幕中自定义按钮发布。 在此处输入图像描述

然后我使用了以下代码:

namespace PX.Objects.AP
{
  public class APReleaseProcess_Extension : PXGraphExtension<APReleaseProcess>
  {
  public delegate List<APRegister> ReleaseDocProcDel(JournalEntry je, ref APRegister doc, PXResult<APInvoice, 
                                                    CurrencyInfo, Terms, Vendor> res, bool isPrebooking, 
                                                    out List<INRegister> inDocs);
  [PXOverride]
  public List<APRegister> ReleaseDocProc(JournalEntry je, ref APRegister doc, 
                                        PXResult<APInvoice, CurrencyInfo, Terms, Vendor> res, 
                                        bool isPrebooking, 
                                        out List<INRegister> inDocs, ReleaseDocProcDel del)
  {
      je.RowInserting.AddHandler<GLTran>((sender, e) =>
      {
          GLTran glTran = e.Row as GLTran;
          APTran apTran = PXResult<APTran>.Current;
          if (glTran != null && apTran != null)
          {
              APTranExt apTranEx = PXCache<APTran>.GetExtension<APTranExt>(apTran);
              if (apTran != null && apTranEx.UsrJobOrderNbr != null)
              {
                  GLTranExt glTranEx = PXCache<GLTran>.GetExtension<GLTranExt>(glTran);
                  glTranEx.UsrJobOrderNbr = apTranEx.UsrJobOrderNbr;
              }
          }

          //APInvoice apInv = PXResult<APInvoice>.Current;
          APInvoice apInv = PXSelect<APInvoice,
                                Where<APInvoice.refNbr, Equal<Required<GLTran.refNbr>>,
                                    And<APInvoice.docType,
                                        Equal<Required<GLTran.tranType>>>>>.Select(sender.Graph, glTran.RefNbr, glTran.TranType);

          if (glTran != null && apInv != null)
          {
              GLTranExt glTranEx = PXCache<GLTran>.GetExtension<GLTranExt>(glTran);
              glTranEx.UsrInvoiceNbr = apInv.InvoiceNbr;
          }

          APTaxTran apTaxTran = PXResult<APTaxTran>.Current;
          if (glTran != null && apTaxTran != null)
          {
              APTaxTranExt apTaxTranEx = PXCache<APTaxTran>.GetExtension<APTaxTranExt>(apTaxTran);
              if (apTaxTran != null && apTaxTranEx != null)
              {
                  GLTranExt glTranEx = PXCache<GLTran>.GetExtension<GLTranExt>(glTran);
                  glTranEx.UsrNoSeriFaktur = apTaxTranEx.UsrNoSeriFaktur;
                 }

              }

          }
              );
          return del(je, ref doc, res, isPrebooking, out inDocs);
      }
  }
}

我尝试调试此代码,但没有命中断点,这是自定义按钮释放的正确方法吗?有人知道这个问题吗?

标签: c#customizationacumaticaerp

解决方案


在 Acumatica 自定义项目编辑器中,在该CODE部分中,在 APReleaseProcess 上添加图形扩展。然后打开生成的代码文件并使用操作按钮OVERRIDE METHOD。在列表中选择目标方法并单击SAVE按钮。这将为您正在使用的 Acumatica 版本插入正确的事件处理程序:

在此处输入图像描述

namespace PX.Objects.AP
{
  public class APReleaseProcess_Extension : PXGraphExtension<APReleaseProcess>
  {
    #region Event Handlers
    public delegate List<APRegister> ReleaseDocProcDelegate(JournalEntry je, APRegister doc, Boolean isPrebooking, ref List<INRegister> inDocs);
    [PXOverride]
    public List<APRegister> ReleaseDocProc(JournalEntry je, APRegister doc, Boolean isPrebooking, ref List<INRegister> inDocs, ReleaseDocProcDelegate baseMethod)
    {
      return baseMethod(je,doc,isPrebooking,inDocs);
    }
    #endregion
  }
}

推荐阅读