Basically i want to create a new action button On Print Invoice and Memos screen to print a report for selected invoices.
Why we are creating new action button is, here we need to print different formats for each invoice (SO type) so when user selects 3 different records in grid for an example 1. INV1234 and so type is TS then i need to print xyz report 2. INV9875 and this has not created through SO then i need to print ABC report 3. CRM4567 and SO type is TS (like above 1 option)
so here 1 & 3 should print in one page (Like same how process button is working in default acumatica) 2 option report should print in new tab.
If i get a sample code on to print same report in single page and other one in another tab is fine.
Below is the code
public PXAction<PrintInvoicesFilter> PrintReport;
[PXUIField(DisplayName = "Print Sales Invoice with Price", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
[PXLookupButton]
public virtual IEnumerable printReport(PXAdapter adapter, [PXString] string reportID)
{
PXReportRequiredException ex = null;
foreach (ARInvoice doc in Base.ARDocumentList.Cache.Cached)
{
var parameters = new Dictionary<string, string>();
if (doc.Selected == true)
{
ARTran TranData = PXSelectReadonly<ARTran, Where<ARTran.tranType, Equal<Required<ARTran.tranType>>,
And<ARTran.refNbr, Equal<Required<ARTran.refNbr>>>>>.Select(Base, doc.DocType, doc.RefNbr);
if (TranData != null)
{
if (TranData.SOOrderType == "WS" || TranData.SOOrderType == "WO" || TranData.SOOrderType == "TS" || TranData.SOOrderType == "IM")
{
if (reportID == null) reportID = "KR501011";
if (reportID == "KR501011")
{
parameters["DocType"] = doc.DocType;
parameters["RefNbr"] = doc.RefNbr;
}
ex = PXReportRequiredException.CombineReport(ex, "KR501011", parameters,false);
}
if (TranData.SOOrderType == "RX")
{
if (reportID == null) reportID = "KR501016";
if (reportID == "KR501016")
{
parameters["DocType"] = doc.DocType;
parameters["RefNbr"] = doc.RefNbr;
}
ex = PXReportRequiredException.CombineReport(ex, "KR501016", parameters,false);
}
if (string.IsNullOrEmpty(TranData.SOOrderType))
{
if (reportID == null) reportID = "KR501038";
if (reportID == "KR501038")
{
parameters["DocType"] = doc.DocType;
parameters["RefNbr"] = doc.RefNbr;
}
ex = PXReportRequiredException.CombineReport(ex, "KR501038", parameters,false);
}
}
}
}
if (ex != null)
{
ex.Mode = PXBaseRedirectException.WindowMode.New;
ex.SeparateWindows = false;
throw ex;
}
Thanks in advance.