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.
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@
Answers
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.
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html
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.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
I said it was something silly.
:oops:
Mat
I have seen the future and it's egg shaped.