Hello together: I just found out that Navision can have the same primary key values in several records. I’m not 100% sure how this happened but I’m trying to solve that issue for quite some time now already. I have created a table with one field only (type RecordID). So this field is also the primary key. Under certain circumstances you can have the same recordID in two different rows. I’m trying to find out how this can happen.
OK, I was able to create a simple FOB to show what happens. Table 60000: two fields (one for Primary Key one is just a checkmark to mark a duplicate). Codeunit 60000: Just running through two tables and writing the recordIDs of the records in those tables into the table. Then running through those tables again and try to find the record with the recordID. If not found, new record is created and marked as duplicate. Just run the table after the codeunit and look for lines with a checkmark set. http://www.brodkorb.at/images/DoublePrimaryKey.rar http://www.brodkorb.at/images/DoublePrimaryKey.fob
Can you put it in the uploads section, I can’t access that from the link.
Unfortunately not, I get a server error when trying to open the link to the “Downloads”
Hehe, I had to change it to a RAR file. Now it should work.
And now it’s also in the download section !!! Some more information: It seems to be always the same records which are duplicate. When you turn the order to descending when writing, it is a different set of records. I think that is very weird.
OK, Ladies and Gentlemen, I think I found the issue: If you overwrite a field of the type RecordID, then you do not really overwrite it [;)] Example: Table 3 “Payment Terms” CM COD 21 DAYS 7 DAYS ← This one will fail when being written to the RecordID field of the log table. The reason seems to be that the length of a RecordID is different within the same table. When you assign a RecordID to a field (maybe also to a RecordID variable, I’m not sure) the system just overwrites the number of bytes of the new RecordID and seems to leave the rest untouched. Also it cannot be displayed (most probably because of a kind of EndOfValue or CHR(0) at the end of the record ID) but the value still stands in the database. So both RecordIDs seem to be the same but in fact they are not. Workaround: CLEAR(Table.“Record ID”); just before assigning the new RecordID.