Filtering on field type RecordID can be tricky because there is a difference between NAV2009SP1 and the versions before.
I want find the record links of a record in the database. (In my example I just used the first record in table 3:”Payment Terms” for which to find its records).
I created a form on table 2000000068:”Record Link” (the existing form is a system form you cannot control). In the OnOpenForm I have put some code to filter only the recordlinks of my payment terms-record
In NAV2009SP1 it is this:
recPaymentTerms.FINDFIRST;
rer.GETTABLE(recPaymentTerms);
SETCURRENTKEY(”Record ID”);
SETRANGE(”Record ID”,rer.RECORDID);
Now, trying this same code in NAV2009 or NAV5.0SP1 does NOT work. Why? Well I don’t know!
But I do know you can find it with a little trick: Change the SETRANGE with a SETFILTER and do a FORMAT of the RECORDID.
NAV50SP1+NAV2009:
recPaymentTerms.FINDFIRST;
rer.GETTABLE(recPaymentTerms);
SETCURRENTKEY(”Record ID”);
SETFILTER(”Record ID”,FORMAT(rer.RECORDID));
Читать дальше