I'm trying to write a process screen in Acumatica ERP 2021R2 (version 21.210.0030) that will generate a financial report for each selected branch in the grid, combine them, and open the combined report when all of them are created.
I know how to do this with reports that are created in the report designer, but this will not work with the financial reports that are created with the Report Definitions screen.
If there are parameters that are requested for the report, the report will not run even when passing the parameters to the
PXReportRequiredException
. It will just open the entry screen for the report where the parameters can be entered before you can manually run the report, which defeats the whole purpose of the process screen.If no parameters are requested, the report will run with the default parameter values defined on the Report Definitions screen. However, if I try to use the
PXReportRequiredException.CombineReport
method when multiple reports need to be combined, it only generates a blank single-paged report instead of combining multiple reports together.I've even gone as far as to attempt to edit the
RMDataSource
record where the default values for the parameters come from before generating the report. This worked for generating a report for a single branch but obviously did not work for multiple b/c it would attempt to use the same parameters for all reports.
Here is the process delegate that I'm trying to use (which behaves as I have described above):
public static void GenerateReports(List<BranchBAccount> branches, RPBranchProcessFilter filter)
{
RPBranchReportProcess dummyGraph = PXGraph.CreateInstance<RPBranchReportProcess>();
Ledger ledger = Ledger.PK.Find(dummyGraph, filter.LedgerID);
Dictionary<string, string> parameters =
new Dictionary<string, string>
{
["LedgerID"] = ledger.LedgerCD,
["StartPeriod"] = filter.FromFinPeriodID,
["EndPeriod"] = filter.ToFinPeriodID
};
PXReportRequiredException reportEx = null;
foreach (BranchBAccount branch in branches)
{
parameters["StartBranch"] = branch.BranchBranchCD;
parameters["EndBranch"] = branch.BranchBranchCD;
reportEx = PXReportRequiredException.CombineReport(reportEx, "RM000007", parameters, false);
}
if(reportEx != null)
{
reportEx.Mode = PXBaseRedirectException.WindowMode.New;
reportEx.SeparateWindows = false;
throw reportEx;
}
}
I've been able to find absolutely no documentation on handling financial reports from the code, so any help would be appreciated.