Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / Entity update with no ...
Finance forum
Unanswered

Entity update with no natural key

Posted on by 242
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
    André Arnaud de Cal... 290,277 Super User 2024 Season 2 on at
    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
    DELDYN 242 on at
    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
    André Arnaud de Cal... 290,277 Super User 2024 Season 2 on at
    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
    DELDYN 242 on at
    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
    Martin Dráb 228,137 Most Valuable Professional on at
    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.

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 9th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,277 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,137 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans