Skip to main content
Answer

How to filter the inserted records with a Button

  • May 6, 2024
  • 2 replies
  • 63 views

Forum|alt.badge.img

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; }
}

 

Best answer by orlandonegron43

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

2 replies

Forum|alt.badge.img

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


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • May 6, 2024

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