Hi there,
I have a DAC called VendorAccountMapping and tried to the field of AP Account in Bills and Adjustments screen via this code:
public class APInvoiceEntry_Extension : PXGraphExtension<APInvoiceEntry>
{
//protected void APInvoice_VendorID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
protected void _(Events.FieldUpdated<APInvoice, APInvoice.vendorID> e)
{
APInvoice row = (APInvoice)e.Row;
VendorAccountMapping vendorAccountMapping = SelectFrom<VendorAccountMapping>.Where<VendorAccountMapping.vendorID.IsEqual<@P.AsInt>.And<VendorAccountMapping.branchID.IsEqual<@P.AsInt>>>.View.Select(this.Base, row.VendorID, row.BranchID);
if (vendorAccountMapping != null)
{
row.APAccountID = vendorAccountMapping.APAcctID;
}
}
}
Weirdly enough, the above piece of code does not work but I have tried the similar piece of code as shown below for Checks and Payments screen and it works without any issues:
public class APPaymentEntry_Extension : PXGraphExtension<APPaymentEntry>
{
//protected void APPayment_VendorID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
protected void _(Events.FieldUpdated<APPayment, APPayment.vendorID> e)
{
APPayment row = (APPayment)e.Row;
VendorAccountMapping vendorAccountMapping = SelectFrom<VendorAccountMapping>.Where<VendorAccountMapping.vendorID.IsEqual<@P.AsInt>.And<VendorAccountMapping.branchID.IsEqual<@P.AsInt>>>.View.Select(this.Base, row.VendorID, row.BranchID);
if (vendorAccountMapping != null)
{
row.APAccountID = vendorAccountMapping.APAcctID;
}
}
}
Can anyone assist on why it behaves differently for APInvoice?