Create Button Under Actions To Redirect To Report In Acumatica

ⅰ亾dé卋堺 提交于 2019-12-24 16:33:48

问题


I am trying to add an option under Actions in Acumatica on the Checks & Payment screen AP302000. See below what I am trying to achieve:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
using PX.Common;
using PX.Data;
using PX.Objects.CM;
using PX.Objects.CA;
using PX.Objects.CS;
using PX.Objects.GL;
using PX.Objects.CR;
using PX.Objects;
using PX.Objects.AP;

namespace PX.Objects.AP
{
  
  public class APPaymentEntry_Extension:PXGraphExtension<APPaymentEntry>
  {

    #region Event Handlers
      public PXAction<APPayment> ShowURL; 
      [PXUIField(DisplayName = "Print Remittance")] 
      [PXButton]
        
      protected virtual void showURL() 
      { 
          APPayment doc = Document.Current;
          if (doc.RefNbr != null) {
            throw new PXReportRequiredException(doc.RefNbr, "AP991000", null);
          }
      }

    #endregion

  }


}

This is however telling me that there is no definition and no extension method for 'APPayment'. Can someone please walk me through how to achieve what I am trying to do?

Note that the report has only 1 parameter (RefNbr)

Thanks, G


回答1:


To Add a new Action in existing Actions Menu, you should override the Initialize() method and use AddMenuAction.

public class APPaymentEntry_Extension : PXGraphExtension<APPaymentEntry> 
{
   public override void Initialize()
   {
      Base.action.AddMenuAction(ShowURL);
   }

   public PXAction<APPayment> ShowURL;
   [PXUIField(DisplayName = "Print Remittance")]
   [PXButton]
   protected virtual void showURL()
   {
        APPayment doc = Base.Document.Current;
        if (doc.RefNbr != null)
        {
            throw new PXReportRequiredException(doc, "AP991000", null);
        }
   }
}

Document.Current should be accessed as Base.Document.Current in Extensions. You need to pass the DAC as first parameter in PXReportRequiredException if DAC has the appropriate parameter value. Alternatively, you can build parameters and pass it to PXReportRedirectException.

Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters["ParameterName1"] = <Parameter Value>;
...
throw new PXReportRequiredException(parameters, <reportID>, "Report")


来源:https://stackoverflow.com/questions/33274465/create-button-under-actions-to-redirect-to-report-in-acumatica

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!