Solved

Add Field Value From Customer Screen to Custom Form

  • 20 December 2022
  • 3 replies
  • 80 views

Userlevel 3
Badge +1

Hi, I need to add a field value in the customers form to my custom form. I tried using field selecting to achieve this but no value is populated to the custom form.

custom form field needed to populate
value needed from customer form
protected void NCPMCustomerMaster_Outstanding_FieldSelecting(PXCache cache, PXFieldSelectingEventArgs e)
{
NCPMCustomerMaster row = (NCPMCustomerMaster)e.Row;
if (row != null)
{

Customer customerObj = PXSelect<Customer, Where<Customer.acctCD, Equal<Required<Customer.acctCD>>>>.Select(this, row.CustomerIntType);
if (customerObj != null)
{

row.Outstanding = customerObj.Balance;

}
}
}

 

icon

Best answer by andriikravetskyi35 20 December 2022, 16:54

View original

3 replies

Userlevel 5
Badge +2

@TharidhiP try this alternative version to your logic

protected void NCPMCustomerMaster_Outstanding_FieldSelecting(PXCache cache, PXFieldSelectingEventArgs e)
{
NCPMCustomerMaster row = (NCPMCustomerMaster)e.Row;
if (row != null)
{

Customer customerObj = PXSelect<Customer, Where<Customer.acctCD, Equal<Required<Customer.acctCD>>>>.Select(this, row.CustomerIntType);
if (customerObj != null)
{

e.ReturnValue = customerObj.Balance;

}
}
}

Also, make sure that the variable customerObj is not NULL. You appear to be comparing a string (Customer.acctCD) to an integer (row.CustomerIntType)

Userlevel 5
Badge +1

Hi everybody,

Customer DAC doesn’t have Balance field, so the compiler send error during build of project.

You need to use ARBalances table and select balance from it, like this:

var arBalance = SelectFrom<ARBalances>.Where<ARBalances.customerID.IsEqual<@P.AsInt>>.View.Select(this, row.CustomerIntType)?.TopFirst;

e.ReturnValue = arBalance?.CurrentBal;

Userlevel 3
Badge +1

Hi, @andriikravetskyi35 thank you for the help!

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