Solved

Find sum of all values in a column

  • 17 February 2023
  • 2 replies
  • 313 views

Userlevel 4
Badge

Have added a custom field on the Grid(Volume) to display the volumes of the Inventory Items during transfer.

Have also created another field(Total volume) to calculate the total volume.

see below;

 

 

Kindly assist on code to calculate the sum of the volumes and be displayed on Total volume Field.

And also  please assist on- Created the Volume field as decimal(19,6). But the output is rounded off. Please share some insights on this too.

Thank you all.

Any kind of response will be appreciated.

icon

Best answer by andriikravetskyi35 17 February 2023, 15:44

View original

2 replies

Userlevel 5
Badge +1

Hi,

I suggest to try PXFormula attribute, all steps you could find in T210 courses, or another way is to develop method that will recalculates Total and invoke it in FieldUpdated and RowDeleted events

Userlevel 7
Badge +8

As @andriikravetskyi35 pointed out the best, easiest and most reliable option is to use PXFormula attribute on your ChildDACExt.UsrVolume field something like

[PXFormula(null, typeof(SumCalc<ParentDACExt.UsrTotalVolume>))]

the null can be replaced by any calculation for the field itself.

this will automatically take care of the aggregation of child field to the header. Also there are a few other aggregation function in Addition to SumCalc that you can find in the guide.

just be advised:

  1. I personally have a bad experience of performance degradations when you have a high traffic screen with many lines and many calculated columns (I had this on an screen with over 500 lines in each document and 60 calculated columns that I had to revise my method completely and push it to Persist)
  2. this will get the status quo of the header field and adjust for changes in the detail. So, going forward on new documents your are all set but if you need accurate and correct values on the existing documents you will need to run a SQL script to fix exiting data OR write a method an run to fix the existing documents totals OR override your document Persist method that loops through your document lines when you save and calculates the totals and updates the document totals.

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