【问题标题】:APReleaseProcess_Extension customize code doesn't work in Acumatica ERP Version 2017 R2APReleaseProcess_Extension 自定义代码在 Acumatica ERP 版本 2017 R2 中不起作用
【发布时间】:2021-06-15 12:45:06
【问题描述】:

我尝试在“发布 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# customization acumatica erp


    【解决方案1】:

    在 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
      }
    }
    

    【讨论】:

    • 嗨 Hugues,感谢您的回答。关于您的代码,似乎与我的代码没有区别。但是我没有为现有的 BLC 执行覆盖方法的步骤。此步骤对于覆盖 BLC 是否是强制性的?如果我执行此步骤,是否会在调试处理中命中断点?
    • 方法参数看起来不同,但您确实在答案中使用了 PXOverride,这是正确的。关于断点,你能证明符号被正确加载了吗?或者更好的是,您可以抛出异常而不是使用断点进行故障排除吗?在屏幕截图中没有选择任何行进行处理,您是否在单击释放之前先选择了一行?
    猜你喜欢
    • 2022-11-10
    • 2021-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多