Solved

How to filter the inserted records with a Button


Userlevel 2

Good Day,

In the screen of Checks and Payments, I need the lines of the grid filtered by Branch, when I select a vendor and add a new line I am filtering the options in the reference Nbr selector by the Branch/Company the user is logged on, but I also need to have the records filtered when I press the tab button "LOAD DOCUMENTS”

When I debugg the code, the foreach goes through the lines I need, but when I stop debugging it inserts every document from any Branch, not sure if it is because I am returning the baseMethod but I would appreciate assistance or some ideas on how I could insert only the records filtered.

 public class APPaymentEntry_Extension : PXGraphExtension<PX.Objects.AP.APPaymentEntry>
{
#region Event Handlers

public delegate IEnumerable LoadInvoicesDelegate(PXAdapter adapter);
[PXOverride]
public virtual IEnumerable LoadInvoices(PXAdapter adapter, LoadInvoicesDelegate baseMethod)
{

PXSelectBase<APInvoice> invoiceQuery = new PXSelect<APInvoice,
Where<APInvoice.vendorID, Equal<Current<Vendor.bAccountID>>,
And<APInvoice.branchID, Equal<Current<AccessInfo.branchID>>,
And<APInvoice.status, Equal<APDocStatus.open>>>>>(Base);

foreach (APInvoice inv in invoiceQuery.Select())
{
APAdjust adj = new APAdjust
{
AdjdBranchID = inv.BranchID,
AdjdDocType = inv.DocType,
AdjdRefNbr = inv.RefNbr,
AdjdDocDate = inv.DocDate,
AdjdFinPeriodID = inv.FinPeriodID,
CuryWhTaxBal = inv.CuryWhTaxBal,
CuryDocBal = inv.CuryDocBal,
};
Base.Adjustments.Insert(adj);
}
return baseMethod(adapter);
}
}
}
#endregion

public class APAdjust_Extension : PXCacheExtension<PX.Objects.AP.APAdjust>
{
[PXMergeAttributes(Method = MergeMethod.Append)]
[PXRestrictor(typeof(Where<APInvoice.branchID, Equal<Current<AccessInfo.branchID>>>), "")]
public virtual string AdjdRefNbr { get; set; }
}

 

icon

Best answer by orlandonegron43 6 May 2024, 22:44

View original

2 replies

Userlevel 2

I figured it out, it was because of returning the baseMethod, I just changed it to return adapter.Get(); and now is working.

Userlevel 7
Badge

Thank you for sharing your solution with the community @orlandonegron43!

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved