Report only retunring one record

MatStephensSandA
Member Posts: 74
Hi all.
Up until this morning i thought i was a compitent coder in Nav. But how wrong i was!!!
We run on a Native 2.6 DB with 3.7 clients.
I am creating the most basic of reports to modify the salesperson field on individual tbales, ie customer item and a custom table calls stock Batch. It simply will not work and i dont know why.
The report is supposed to filter on the salesperson then for each record found modify the salesperson field with a new value. Instead of doing this the report returns one record and modifies it (correct so far) but then moves on to the next Dataitem rather than the next record in that filterset. It must be something so obvious and silly but i just can not see it.... ](*,)
I have a single report that has 3 Data items.
Each Data item is filtered on by one variable and modified to the second variable.
Filter = OldSP
Modify = NewSP
My code is like so;
In the properties of the dataItem it is sorted by salesperson.
If i specify an alternate key in the properties then the report functions correctly.
however it then takes hours to run.
I have been looking at this issue for ages now and i cant see the forrest for the trees.
All help / advice very much aprechiated
thanks
M@
Up until this morning i thought i was a compitent coder in Nav. But how wrong i was!!!
We run on a Native 2.6 DB with 3.7 clients.
I am creating the most basic of reports to modify the salesperson field on individual tbales, ie customer item and a custom table calls stock Batch. It simply will not work and i dont know why.
The report is supposed to filter on the salesperson then for each record found modify the salesperson field with a new value. Instead of doing this the report returns one record and modifies it (correct so far) but then moves on to the next Dataitem rather than the next record in that filterset. It must be something so obvious and silly but i just can not see it.... ](*,)
I have a single report that has 3 Data items.
Each Data item is filtered on by one variable and modified to the second variable.
Filter = OldSP
Modify = NewSP
My code is like so;
In the properties of the dataItem it is sorted by salesperson.
Item - OnPreDataItem() Window.UPDATE(1,'Item'); SETFILTER(Salesperson,'%1',OldSP); RecTotal := COUNTAPPROX; RecCount := 0; Item - OnAfterGetRecord() Salesperson := NewSP; MODIFY; RecCount +=1; Window.UPDATE(2, ROUND(RecCount/RecTotal*10000,1));The same code is called on each dataitem.
If i specify an alternate key in the properties then the report functions correctly.
however it then takes hours to run.
I have been looking at this issue for ages now and i cant see the forrest for the trees.
All help / advice very much aprechiated
thanks
M@
M@
I have seen the future and it's egg shaped.
I have seen the future and it's egg shaped.
0
Answers
-
Hi Mat (M@ - 8) )
The problem is arising because the modify in the onaftergetrecord trigger. It record position is changed and therefore outside the filter on the old salesperson code hench only updating one record. Use a record variable and all should be fine.0 -
Something like:
Item - OnAfterGetRecord() recTheRecord := "Your DataItem-record"; recTheRecord.Salesperson := NewSP; recTheRecord.MODIFY;
In general: if you loop a record-set and have to change a field in it, it is a good idea ALWAYS to use a new variable to change a field. Sometimes it is not necessary, but I advice to ALWAYS do it.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Thanks your both wonderful!
I said it was something silly.
:oops:
MatM@
I have seen the future and it's egg shaped.0
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