Hi,
we are upgrading a NAV 2009 R2 Database to 2016. There are some 3rd party objects, and some of them don't work the same way in new NAV. In 2009 I've such code:
_Rec.SETRANGE(Code, _Code);
_RecordRef.OPEN(_TableNo);
_RecordRef.SETTABLE(_Rec);
IF NOT _RecordRef.FIRST THEN EXIT(0);
_FieldRef := _RecordRef.FIELD(_FieldNo);
in 2009 both _RecordRef and _Rec have the same filters applied after this code executes. In 2016 not anymore and the _RecordRef is taking the first record from the table.
In MSDN I read that SETTABLE actually should set the table of the Record Variable as the same as RecordRef variable. This would mean that above code is completely wrong, it should use the GETTABLE function. But why it worked in 2009? Or is this somekind of a bug in 2016?
I found over 300 usages of this function in this small add-on, and now we need to decide if we need to correct all this lines and be sure that it will not brake after future 2016 CU.
0
Answers
So the code is wrong. However, I remember there was a bug in some builds (probably 2009 something) which caused this wrong behavior.
BTW: You do not need to OPEN the RecordRef before GETTABLE.
Carsten
==> How To Ask Questions The Smart Way
This post is my own opinion and does not necessarily reflect the opinion or view of my employer.