Wednesday, May 1, 2024

D365 F&O - When posting Service Orders, Project Item Journals, Item Transfer Journals, A key with the name 0.00 already exists.

 Recently we ran into an issue when posting Service orders, project item journals, or item transfer journals with multiple lines.  The error we received is:

Check - Journal Journal: 000341 A key with the name 0.00 already exists.

In looking deeper, it seemed that the issue was a violation of the primary key on the InventJournalTrans table that is associated with the voucher.  The actual error is occuring in classes\JournalTransList\selectDB class\method.  Inside that class the 'add' method is called and when calling 'ins' on a RecordInsertList it is failing.

In doing some searching I found a post for AX 2009 here.  This post is nearly 15 years old!  However, my situation is the exact same.  I have an extension of the InventJournalTrans where I added the SMAServiceOrderLineNum field which extends the 'LineNum' EDT.  This was causing the system to think my custom field was part of the index and therefore throwing the error on multiple lines.

Solution:

As mentioned in the link, create your own Real EDT that extends 'LineNum' and use that for your field on the table.

No comments:

Post a Comment