web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

natural key for custom tables

(0) ShareShare
ReportReport
Posted on by 1,552
Hi,

We all know that if we want to create an entity for a table without natural key, then we can copy an existing entity then start replacing nodes.

My question is for custom tables. Let's say I created a new table, where i know that there is no unique key for it -- in this case, if i want to create an entity, shall i duplicate the entity OR is it a best practice to always have a unique key for the table?
in this case, maybe that would mean to create an auto incremented field by code and make it unique?
I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    236,320 Most Valuable Professional on at
    natural key for custom tables
    There should be a unique key, because saying that you can have rows with the same values in all fields looks useless. Why would you store rows with identical values instead of just storing the record once (and refer to it from multiple places, if needed)? It's often caused by a mistake in the data model design.
    But yes, there may be cases when creating such a key isn't practical and you use a synthetic key as the only unique key. You don't need to create a new field, though, because you already have such a field that is populated automatically: RecId.
  • Suggested answer
    GirishS Profile Picture
    27,825 Moderator on at
    natural key for custom tables
    Hi Junior,
     
    My suggestion will be the second one as you said - best practice to always have unique key for the tables when creating entity for.
    As you said you can just create autoincrement of numbers. For example, you can create Line Num field in a table and autoincrement it via code.
    Refer to the below blog.
     
    Thanks,
    Girish S.
  • junior AX Profile Picture
    1,552 on at
    natural key for custom tables
    Hi Martin,

    Maybe you could think of it as a log table, so data can be repeated -- I didn't get what you mean by synthetic key?
    so are you saying that i should create the entity without a natural key using the workaround?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,100

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 890 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 633 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans