Open a Report in Acumatica

Hi All,

Following a previous post about redirection architecture I want to show you an example of how can you use it to open a report.

Here we need to use PXReportRequiredException, as it designed to open reports. But also we need to provide a report name and report parameters.

  • Report Name is just a Screen ID that you can find in the sitemap
  • Report Parameters is a Dictionary<string, string> that is basically a key-value pair. Key is a parameter name and value is a value. Parameter names are taken directly from the report.

Here is the example code to create a button for report. I get this code from Receipt Screen in Inventory Module.

public PXAction<INRegister> iNEdit;
[PXUIField(DisplayName = Messages.INEditDetails, MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
[PXLookupButton]
public virtual void INEdit()
{
      if (receipt.Current != null)
      {
            // create the parameter for report
            Dictionary<string, string> parameters = new Dictionary<string, string>();
            parameters["DocType"] = receipt.Current.DocType;
            parameters["RefNbr"] = receipt.Current.RefNbr;
            parameters["PeriodTo"] = null;
            parameters["PeriodFrom"] = null;
            
            // using Report Required Exception to call the report
            throw new PXReportRequiredException(parameters, "IN611000", Messages.INEditDetails);
      }
}

Hope it helps!

1 Reply to “Open a Report in Acumatica”

Leave a Reply

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