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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Is it ok to have index on RecId ?

(0) ShareShare
ReportReport
Posted on by 596

Hi guys,

I have a custom table that currently use as staging table and it is possible at some time most of the field (not all) are same, However I need to have index with eventually will be a primary index since I'm gonna need to create data entity of it. In my understanding, we should have primary index which obviously will need unique value.

May I know what is the solution of this? I am thinking of just use RecId as the field in my index, would it be fine ? or is there better approach ?

Thanks,

I have the same question (0)
  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    Is your intention to import data through this entity, or will it be a readonly entity used for export only?

  • Voltes Profile Picture
    596 on at

    Hi Martin,

    It is for export only. I need to create that data entity because just found out it is mandatory so that I can have the feature "Open In Excel" when open from SysTableBrowser.

  • Suggested answer
    Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    If it's just for export (you won't be able to pub;ish data from Excel), then having RecId as an entity key isn't a big deal.

    Nevertheless I would still think about a natural key of the table.

  • Voltes Profile Picture
    596 on at

    Yes, I think I won't need to publish data. But out of curiosity does it mean by using RecId will make it unable to publish or is there anything else ?

    May I know what about the natural key ? I'm sorry I just do not play around with tables key until recently, so might need further explanation of what I should consider.

    Thanks,

  • André Arnaud de Calavon Profile Picture
    301,109 Super User 2025 Season 2 on at

    Hi Lars,

    Let's take a standard table as example to illustrate the issue for using record IDs as entity key for a data entity.

    The customer groups table has a primary index on the field Customer group. It will not allow for duplicates. When you create a new record, it will generate a unique record ID as well. The record ID value itself does not have any meaning. It can be used for references in other tables.

    When you create the same customer group in another environment, it will have another record ID.

    Now when you import data using a data entity, it will try to find existing records based on the entity key. If this is the customer group, it can find a match and would update a record. If there is no existing record, it will create a new one. When the entity key is the record ID, it will not find the same record (as the record ID is different) and will try to create a second customer group with the same customer group ID.

  • Voltes Profile Picture
    596 on at

    Hi,

    Yes, I'd just remembered about this natural key thing. There is "Natural key" error in Data Entity Wizard if we do not have Primary key with our own field, and it also doesn't accept if RecId is part of the index when create Data entity.

    So is there a better approach how to have a primary index when most of the fields may have same value ?

    Thanks,

  • Verified answer
    André Arnaud de Calavon Profile Picture
    301,109 Super User 2025 Season 2 on at

    HI Lars,

    Above, you mentioned that the data entity will be used for export only. In this scenario, you don't have to worry about the entity key. There are several tables in the standard application having multiple fields to determine the primary key. In that scenario it is not an issue to list e.g. 5 fields as the entity key.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 451 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans