Skip to main content
Answer

How to get the sum of a field in the line level of the grid and show in a header level field

  • August 28, 2023
  • 2 replies
  • 294 views

Forum|alt.badge.img+1

As shown in the above screenshot, I want to get the total of the “Line Volume” in the detail section and show in the field of Total Volume in the header level. This Line Volume is a newly added customized field in to the ARTran DAC. Relevant code for the Line Volume as follows.  

Guys, If you can give me a guidance, it is highly appreciated. 

Best answer by KumarDighe

Hi @malinthawarnakulasooriya08,

I have similar requirement before to get the Invoice amount total on Project billing screen

I did the following code on row selected event to get the same.

  var getBugetLines = PXSelect<PMRevenueBudget, Where<PMRevenueBudget.projectID, Equal<@P.AsInt>>>.Select(Base, row.ProjectID);

if (getBugetLines == null) return;

// Loop through the budget records and sum up the invoiced amounts
foreach (PMBudget budgetRecord in getBugetLines)
{
// Retrieve the invoiced amount from the CuryAmountToInvoice field
decimal invoicedAmount = budgetRecord.CuryAmountToInvoice.GetValueOrDefault();



// Add the invoiced amount to the total
invoicedAmountTotal += invoicedAmount;
}
e.Cache.SetValueExt<ProjectsListExt.usrInvoiceAmountToPay>(row, invoicedAmountTotal);

You just need to use your DAC and Fields to get the Total Volume.

Let us know this will help you or not.

Regards,
Kumar

2 replies

darylbowman
Captain II
Forum|alt.badge.img+15

You are supposed to be able to use PXFormula to accomplish this, but according to this article, there may be an issue with that. I would try the PXFormula, and if it still hasn’t been fixed, use one of the other events.


  • Freshman II
  • Answer
  • August 28, 2023

Hi @malinthawarnakulasooriya08,

I have similar requirement before to get the Invoice amount total on Project billing screen

I did the following code on row selected event to get the same.

  var getBugetLines = PXSelect<PMRevenueBudget, Where<PMRevenueBudget.projectID, Equal<@P.AsInt>>>.Select(Base, row.ProjectID);

if (getBugetLines == null) return;

// Loop through the budget records and sum up the invoiced amounts
foreach (PMBudget budgetRecord in getBugetLines)
{
// Retrieve the invoiced amount from the CuryAmountToInvoice field
decimal invoicedAmount = budgetRecord.CuryAmountToInvoice.GetValueOrDefault();



// Add the invoiced amount to the total
invoicedAmountTotal += invoicedAmount;
}
e.Cache.SetValueExt<ProjectsListExt.usrInvoiceAmountToPay>(row, invoicedAmountTotal);

You just need to use your DAC and Fields to get the Total Volume.

Let us know this will help you or not.

Regards,
Kumar