GaGa
GaGa

Reputation: 209

Create Button Under Actions To Redirect To Report In Acumatica

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

Upvotes: 1

Views: 1205

Answers (1)

DChhapgar
DChhapgar

Reputation: 2340

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")

Upvotes: 5

Related Questions