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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Entity Key

(2) ShareShare
ReportReport
Posted on by 2,005
Hi,

What I understand about entity keys, is that when importing, if i provide an existing value of the entity Key, then it consider it as an update, else insert.

Now, in this entity below (Entity key is partyNumber, locationId and validFrom)
so if i import via DMF an existing value  for the combination of the three fields, then it should consider as an update, else then insert.


so i exported a record with a certain locationId, then I imported the file again but i deleted the locationId column while importing. So i'm assuming since LocationId column is deleted, then it should consider the import as an insert instead of update But, it didn't create a new address and it considered it as an update without changing anything. why??
Categories:
I have the same question (0)
  • Martin Dráb Profile Picture
    239,399 Most Valuable Professional on at
    How did you determine that "it considered it as an update without changing anything".
     
    It can't find a record to update if there is no LocationId to use for searching.
  • .. Profile Picture
    2,005 on at
    Hi Martin,

    Because the import showed a success status and no address got created. So if no address got created, then what happened?


    i provided a combination of the entity key that should result in an insert, but no insert happened and no error appeared.

    and i just noticed that insertEntityDatasource and updateEntitydatasource weren't called when debugging
  • Martin Dráb Profile Picture
    239,399 Most Valuable Professional on at
    Your screenshow shows that one record was created, which contradicts your statement that "it considered it as an update". I hope you now agree that it's not about an update at all.
     
    Maybe you just failed to find the new address. How did you try to do it?
     
    I find highly unlikely that insertEntityDatasource() wasn't called. I rather suspect a problem in your debugging.
  • .. Profile Picture
    2,005 on at
    Hi Martin,
     
    I'm sure the insert method is not called when debugging. 

    I know that no address was created by running this SQL statement:

    select PARTYNUMBER,PARTY,LOCATIONID,DESCRIPTION,VALIDFROM,VALIDTO,CREATEDDATETIME
    ,*from DIRPARTYLOCATIONPOSTALADDRESSV2ENTITY order by RECID desc

    The last createdDateTime was yesterday 

    also this statement, the last modified date time was yesterday
    select ADDRESS,MODIFIEDDATETIME,*From LOGISTICSPOSTALADDRESS order by RECID desc


    i tried the following:
     
    • Importing the same address without removing any fields -- no change (update entity data source was called)  (DMF showed updated as 1)
       
    • importing the same address but Without both (location id and valid from) -- no debug was called and nothing changed  (DMF showed created as 1) 
       
    • importing same address but without validFrom column   -- update entity datasource was called for DirPartyLocation (DMF showed created as 1)
       
    • import same address but without LocationId column-- no method in debugging was called and no change (DMF showed created as 1)
  • Martin Dráb Profile Picture
    239,399 Most Valuable Professional on at
    What if you put breakpoint to mapEntityToDataSource()? You can also debug the data management framework, e.g. DmfEntityWriter.processRecords).
  • Suggested answer
    Alireza Eshaghzadeh Profile Picture
    14,849 Super User 2026 Season 1 on at
    Hi,
    Ensure that the Excel file includes the Location ID field, even if it’s empty. When running the import job, upload the file (e.g., Excel), then click on the mapping table. Set the flag for "Auto-generated" for the "LOCATIONID" field. This will ensure the record is inserted into the parts without being updated.


  • Waed Ayyad Profile Picture
    9,133 Super User 2026 Season 1 on at

    Hi, 

    Is your issue resolved? If yes, mark the answers that helped you as verified. 

    Thanks,

    Waed Ayyad

  • .. Profile Picture
    2,005 on at
    Hi Alireza, 

    it works thank you, but now in case of update, if i keep auto generated as true, it will still consider the update as insert. So it seems i need to keep playing with this tickBox in case i want to update or insert (i thought it will work by itself)

    Hi Martin,

    So I tried the example again, when exporting an existing address, then removing the whole 'LocationId' column from the excel file, and leaving all other fields as is
    - "MapEntityToDatasource" gets called
    - "InsertEntityToDatasource" gets called (not sure why it wasn't called before)
    - "DmfEntityWriter.processRecords" doesn't get called
     
    DMF shows created as one, but nothing really happens



    The code goes there (methods in yellow), it detects that a similar address already exists with the same values by going inside the "Remittance" method, so it considers it as an update somehow (as you can see from the screenshot the comment says "update address as correction")
    So when i go to SQL, no records are created and the code explains it, but at the same time the modifiedDateTime for LogisticsPostalAddress and LogisticsLocation isn't changed as well. Which is weird.

    Also the remmitanceAddress method looks wrong, it doesn't check the validFrom field. As I had two exact addresses with the same values but different validFrom. And when exporting, i chose the one with the latest validFrom, but when i imported, the remittance method brought the other one and made it's validFrom similar to the other validFrom record.
  • Martin Dráb Profile Picture
    239,399 Most Valuable Professional on at
    The query in resolveRemittanceAddressLocationId() does take ValidFrom and ValidTo fields into account. It's not explicitly written in code, because it's handled automatically by the kernel. You may want to read Using date effective data patterns to learn more about it.
  • .. Profile Picture
    2,005 on at
    Hi Martin,

    But it didn't. 

    I had the following in the database
    LocationId  ValidFrom     PartyNumber
    1                  dateTime1        1
    2                  dateTime2         1
     
     
    I imported the following (without LocationId column):
     ValidFrom     PartyNumber
      dateTime2         1
     
    what it did, is that the remittance method returned locationId = 1 instead of 2 and it updated the validFrom for LocationId 1 with dateTime2
    if the remittance method considers validFrom, then it should have returned LocationId 2 and not 1
     
     
     
    and in general, I assumed that the entity key decides the insert or update but it seems no in this case (i need to play with auto generate field for insert) and if i want to update then this field needs to be no

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 637

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 594 Super User 2026 Season 1

#3
CP04-islander Profile Picture

CP04-islander 356

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans