How did you manage to get an item with blank Item No.? This should not be possible.
However I have seen this a few times before, usually because a user have created a dataport that imports / updates items. An item with blank No. is created when the last line in the file is empty.
The history you see for the blank item is probably not related to the blank item. The Item No. on entries is being blanked out if you deleted an item so the entries you see with blank Item No. is probably related to deleted items.
Regards
Claus
P.S.
I forgot to say, I would just delete the item from code and without executing the OnDelete trigger code.
And nobody noticed that while executing transactions over that item?
…
You can (probably) override navision’s “check code” that is checking wheter there are posted documents with that item or not. Everything would probably be ok after that except you’ll have a new item (at least, no Item No.) in a reports. Is there a lot of entries in ledger for it or it’s kind of minor priority item?
I’m not sure you need a “code solution”. At least on SQL server, if you simply rename Item No. it will rename all appropriate table entries (SQL 3.60, though…)
All you need is to bypass check code. If you have downtime (f.e. when nobody is logged on navision) do it in that time:
Comment out check code in Item table (OnModify trigger) and simply rename that Item No.
We did this on several occasions (only on one same clients database and on their explicit request) and it all went well but, do testing, ofcourse…
I missed the problem, I was thinking more about a problem of renaming item that has ledger entries.
Once, I had a same problem with unability to change from empty to non-empty No. and easy solution for me was to delete/create again that entry but in your case that is not applicable…
You do need to be careful here, you will have lines in orders that have Type::Item but a blank “No.” simply because nobody selected the item with the empty “No.”.
The first thing I would do is to write a report to go through each table where the “No.” = ‘’ and after checking order lines and posted document lines, delete the unwanted lines and rename each of the legitimate entries.
You may have to rem out the checks in some of the tables.
I have a client who has a blank “No.” also, but they use it as a generic entry.
To my knowledge you can not bypass the error. Navision will not let you rename a blank primary key if the blank primary key has been used in “related tables”. In you case you can not rename the blank item as item ledger entries exist with blank item no. I guess Navision have made this blocking as Item No is being blanked in Item Ledger Entries when the Item is deleted (same goes for e.g. Customer and Vendor).