Skip to main content
Post a question

Notifications

Community site session details

Community site session details

Session Id : 9K0dCms7zX1MOq9NwatIP4
Finance | Project Operations, Human Resources, ...
Unanswered

Entity update with no natural key

Like (1) ShareShare
ReportReport
Posted on 24 Jan 2024 14:28:07 by 312
Hi,

There is table from a third party, that has an entity with Data management enabled as false.  (Also this table doesn't have a natural key).

So i was asked that we need to update a certain field via a data entity.

So i added this third party model to my model. I created a new entity with this table (i created the entity by a workaround to skip the natural key error that would come if i create the entity from the wizard).
 

Questions:
1. But now what would be the entity key? if I add recId, it means that people will need to add recId in order to update the field and i think it's not good to use recIds for importing.. or would that be the only option in my case?
2. Also can i only allow updates for fields for the entity and not allow inserting a new record?
  • AndrĂ© Arnaud de Calavon Profile Picture
    293,406 Super User 2025 Season 1 on 02 Feb 2024 at 22:44:52
    Entity update with no natural key
    Hi Deldyn,
     
    You are correct that Record IDs shouldn't be used as entity key. It sounds like you found an alternative combination of fields. I would suggest test it carefully and monitor if this would be the correct entity key for your requirement.
  • DELDYN Profile Picture
    312 on 02 Feb 2024 at 13:04:53
    Entity update with no natural key
    Hi Andre,

    There is only one index with allow duplicate no for this table, which has two fields (RecId + Temporary).
    And I can't use RecId when importing as far as I know, as it's not a good practice, or would you have used RecId??

    So based on some analysis myself by looking at records values, I decided to put the following as Entity key (Invoice, InvoiceDate, Voucher, TransDate, VendAccount) -- I think this combination would somehow gurantee me a unique value even though it's not specified as an index in the table.
  • AndrĂ© Arnaud de Calavon Profile Picture
    293,406 Super User 2025 Season 1 on 25 Jan 2024 at 22:35:44
    Entity update with no natural key
    Hi Deldyn,
     
    As we don't know the contents of this table in your environment and we don't know the exact table structure, you are the only person who can check what combination of fields makes a unique record. Looking at the index provided by AXtension, it could be for sure that with any combination you will get duplicates based on one set of fields, or the other, or both.
    Does the table have another index that does not allow for duplicates? If that is the case, you can use that set of fields for the entity key.
  • DELDYN Profile Picture
    312 on 24 Jan 2024 at 15:03:44
    Entity update with no natural key
    Hi Martin,

    it's a table related to purch invoices. (Axtension module, table AXTip_PurchInvoice)
    the table unique index is (RecId and Temporary)

    I think I was able to find something unique which is TransDate  but i'm not sure

    so the following "Invoice, voucher, TransDate" looks unique as i checked SQL and i didn't find any duplicates but i don't know in the future what could happen.

    OR do i need to add vendAccount and DocumentDate(which is the invoiceDate) as well?

    so would the key be 
    Invoice, voucher, TransDate
    OR
    Invoice, voucher, TransDate, vendAccount, DocumentDate
  • Martin Dráb Profile Picture
    232,552 Most Valuable Professional on 24 Jan 2024 at 14:37:13
    Entity update with no natural key
    1. We don't know the table, therefore we can't tell you which field or a combination of fields uniquely identify a record. You'll need to do an analysis.
    2. Yes, it's possible. For example, you can throw an exception in insert() method of your data entity.

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,406 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,552 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans
Loading complete