accumulated balance in page 20

kanika
Member Posts: 247
Hi experts!! NAV2017
I need to add a field on the page with the accumulated balance, like the example

I wrote this code in the OnAfterGetRecord () trigger
IF NOT blnPrimero THEN BEGIN
decAcumulado:=0;
blnPrimero:=TRUE;
END;
decAcumulado+=Amount;
but it does not work
please any suggestions!!
I need to add a field on the page with the accumulated balance, like the example

I wrote this code in the OnAfterGetRecord () trigger
IF NOT blnPrimero THEN BEGIN
decAcumulado:=0;
blnPrimero:=TRUE;
END;
decAcumulado+=Amount;
but it does not work
please any suggestions!!
0
Answers
-
Hi
Just my personal suggestion.
Add accumulated field in Page is not a good practice. Do this in report.
If you really want to do, add accumulated field in table, create a new page and calculate it by action.
0 -
but why???
why is not a good practice??
and
why a new page?0 -
Hi
Well, performace is one concern, and the control of filtering, sorting is another concern.
Again, just my personal opinion.0 -
I thank all the opinions, it is for having a more extensive information0
-
I would not be concerned about any performance issues. What you do is a simply math operation, you would have to run tens of thousands of them to see any impact.
The trouble with Pages is the control of calculation. How do you reset the blnPrimero when user clicks one of headers and change soting order? Or add a filter to get a subset of records?
I would agreed with @allenyyzhou - do it on a report. This is the a place where you can get it working much easier.Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
the question is that as it works well except the first line, from the second the balance is correct until the end
0 -
OnAfterGetRecord is not guaranteed to fire only once on the page . And this is exacly what happend here: it was fired 5 times: 1st on 1st line, then on 2nd, then on 3rd line and then 2 times more on the first one.
Even order in which the records are fetched is not guaranteed. Try scrolling a few lines an then try PageUp or PageDown.
If you want do do this on the page you would need to build much more complicated logic to control when to add up the amount and when to reset it back to 0.Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions