Dynamics ax a key with the name %1 already exists


Today I had to fix a bug in some custom code in Dynamics Ax 2009, we had an error from the JournalTransList class that stated “A key with the name %1 already exists.”

  • Cause: A custom field on the WMSJournalTrans table that was extending from LineNum
  • Reason: The JournalTransList has methods to check if the primary index on the actual table won’t be violated, therefore it seems to look for all fields that extend from LineNum.
  • Solution: Create you’re custom EDT that extends from LineNum and add that one to the table, it’s a best practice but who thought this could be so critical :p

4 responses to “Dynamics ax a key with the name %1 already exists”

  1. Thanks a million! This problem still exists in Microsoft Dynamics 365 for Finance and Operations. I used steps to solve for another client as well.

  2. Hi Kevin,

    Thanks a ton. this really save me hours of debugging. i have custom fields on prod journal bom and same scenario. Just change the edt and and error go way. i never thought this would be the reason.

    • Hi Hammad,

      I’m glad it worked!
      On what version did you have this? I’m curious to see how relevant the post still is 🙂

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.