Adding new Report Button on Invoices and Memos screen

Hi All,

Today want to share with you the case how to add a new button to print alternative Invoice Form right from Invoices and Memos screen.

Invoices and Memos screen.

Lets check how does that work and check how original button “Print Invoice/Memo” is configured.

Automation Steps
Fist of all if you check the code, there is no handler for “Print Invoice/Memo”. That is some sort of virtual button defined through Acumatica Automation Workflow.

Acumatica Automation Workflow

If you check Automation Steps for “Invoices and Memos” screen you can find that menu “Print Invoice/Memo” is added to action “Report”. That is exactly action that will be executed in the code.

If you click “Fill With Values” button you also can see that this action passing some parameters to code.

Acumatica Automation Workflow

Fields with normal name (like “Printed”) are real DAC fields. Acumatica will put there your value when you click on button.
Fields those started with “@” is not a read field, they are parameter of functions in the code.

Code Handler
If you check the code of ARDataEntryGraph (that is a parent ARInvoiceEntry and ARCashSaleEntry) than you can find that action handler:

 Code Handler acumatica

You can see hare that this method has the same name as Action in the Automation Steps and it has parameter – reportID, that was provided from “Fill with Values” dialog box.

Depend on reportID provided that action just fills report parameter from the code. And than just throws the proper PXReportRequiredException:

That’s all, now we know how does it work.

Customization
So accordingly to our investigation, if you need to add new button there we need to do 2 things:

  • Modify a button handler to handle new report ID
  • Amend Automation Steps to register a new Action Menu.

Lets start with the code – here is an example of extension how can you add new report ID to the code:

public class ARInvoiceEntry_Extension : PXGraphExtension<ARInvoiceEntry>
{
       public delegate IEnumerable ReportDelegate(PXAdapter adapter, String reportID);
       [PXOverride]
       public IEnumerable Report(PXAdapter adapter, String reportID, ReportDelegate baseMethod)
       {
              IEnumerable records = baseMethod(adapter, reportID);

              //if we are here that means that report is not identified by base method
              PXReportRequiredException ex = null;
              foreach (ARInvoice doc in records)
              {
                      var parameters = new Dictionary<string, string>();
                      if (reportID == "AR641001")
                      {
                             parameters["ARInvoice.DocType"] = doc.DocType;
                             parameters["ARInvoice.RefNbr"] = doc.RefNbr;

                             ex = PXReportRequiredException.CombineReport(ex, reportID, parameters);
                      }
              }
              if (ex != null) throw ex;

              return records;
       }
}

As soon as it is published, you can use Automation Steps to configure new Action:

Automation Steps acumatica

Please note, that Action will be enabled only on steps where it is defined. That means you may need to add this new action to every single step in Automation (ex Balanced, Hold, Released, etc).
Now you can save everything and test the result.

Automation Steps acumatica

Have a nice customization!

11 Replies to “Adding new Report Button on Invoices and Memos screen”

  1. Hi sergey,
    I want to ask how to call the Purchase Order report button, I want to set the enable button based on the open status, I want to do it using code instead of automation step

    1. The following code is used:
      Base. (Name Action button report) . Setenabled (True):

      What I want to ask is what is the name of the Order Order report button event on Acumatica
      Note :I need the name of the event report button purchase Order delivery

      1. HI Koisuke, I think the Purchase Order report button does not have the type in the code, as this button is not purely with Automation Steps.

          1. Hi Koisuke, I recommend you to do that with Automation Steps. I don’t think it is possible to chance state with code.

  2. Hi,

    I added “Print Cash Receipt” (AR.64.20.00) in the Payments and Applications screen (AR.30.20.00) as it is logical for users to print the form after creating a payment. However, when this is done, the form gets printed out with a blank form. Users have to click on edit and select the payment again to print the form.

    It seems like the Reference number is not passed to the form. How can this be done?

    1. Based on your description it seems you haven’t provided the proper document keys to report parameters. They have to match each other by name.
      If that still a problem post here your code.

  3. Hi Sergey

    I am trying to do this on a new process screen. I mean a new Action for Printing Invoice on a process screen with only Customer Ref Nbr as a parameter for a new report. Can you help me on how to start with this?

    1. Hi Prathyusha,
      If you have a processing screen than you need to write a logic there to run a report from code.
      I think you can just write a code that will throw PXReportRequiredException with report ID and parameters you want to pass there.
      Dictionary dictionary1 = new Dictionary();
      dictionary1[“DocNbr”] = row.DocNbr;
      PXReportRequiredException ex = new PXReportRequiredException(dictionary1, “SW601000”, “B2B Order”);

      ex.Mode = PXBaseRedirectException.WindowMode.New;
      ex.SeparateWindows = true;
      throw ex;

      1. HI Sergey

        I am trying to add a report on ‘Purchase receipt’ screen, but in the automation steps in ‘Fill With Values’, it does not allow me to put in any value ( reportID ) i want, but rather there is a drop down allowing only the selection of existing related reports. Any ideas what is going on here?
        I have successfully added a button to launch a report on the Purchase order screen, it is only in purchaser receipts this issue exists.

      2. Hi Ellie,
        The list of available reports is hardcoded in the action definition. So I guess the best way is to use customization engine to customize action with adding more options. Please see action definition below:

        protected virtual IEnumerable Report(PXAdapter adapter,
        [PXString(8, InputMask = “CC.CC.CC.CC”)]
        [PXStringList(new string[] { “PO646000”, “PO632000”, “PO622000” }, new string[] { “Purchase Receipt”, Messages.ReportPOReceiptBillingDetails, Messages.ReportPOReceipAllocated })]
        string reportID) {

Leave a Reply

Your email address will not be published. Required fields are marked *