Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / Data Entity Export fai...
Finance forum
Suggested answer

Data Entity Export failing: Cannot create a record in staging table, The record Already exists.

Posted on by 150
Hi Community Experts,

I have one custom data entity which has multiple data sources. I have recently added one more data source to apply a Range and afterwards the entity is failing in DMF export project.





Now when I try to use this Entity in a DMF export project (Excel as output format) it is giving following error for around 60+ positions




I have tried the following to solve this issue:
  1. Regenerated the staging table
  2. Checked the index on staging table, its also intact.
  3. Restarted the AOS service.
  4. Full build/Sync the model.
  5. Ran the following query on data entity to check for duplicates
    SELECT TOP 1 COUNT(RECID) AS KEYCOUNT
    FROM HRORGCHARTEXPORTENTITY
    GROUP BY POSITIONID
None has worked so far.

Looking forward to helpful responses on this issue.
 
  • Data Entity Export failing: Cannot create a record in staging table, The record Already exists.
    Hmm... That's interesting.
    Unless other chip in, I'd have a look at the data in the view that F&O generated for the entity, and see if there is any index conflicts for the positions it's complaining about.
     
    These are some of the views F&O generates in the standard application for entities.
     
     
  • alinawaz Profile Picture
    alinawaz 150 on at
    Data Entity Export failing: Cannot create a record in staging table, The record Already exists.
    The problem stands still.
    It is failing while exporting.
     
  • alinawaz Profile Picture
    alinawaz 150 on at
    Data Entity Export failing: Cannot create a record in staging table, The record Already exists.
    I actually don't need those fields in the field list. I had to add them in the Field list of data entity because without having those fields in the list the entity was not building and errors were present. So after I re-generated the staging table these fields came in the staging table too.
     
    Now adding the fields in index of staging table only and changing the join mode back to "InnerJoin".
    Lets see if this builds and Syncs , and afterward I will try to export entity again.
  • Suggested answer
    Data Entity Export failing: Cannot create a record in staging table, The record Already exists.
    Okay, you are using fields from the joined table, based on the error message.
    Then you just need to add the "ValidFrom" and "ValidTo" fields to the index of the staging table and keep the join mode as InnerJoin. Otherwise you will get index conflicts.
  • alinawaz Profile Picture
    alinawaz 150 on at
    Data Entity Export failing: Cannot create a record in staging table, The record Already exists.
    Changed the join mode of the datasource (HcmPosition). Now its not building.
     
  • Data Entity Export failing: Cannot create a record in staging table, The record Already exists.
    Yep, I added another suggestion (-:
    Think the community board had an issue, could not see the text of your question.
     
    But definitely something to do with the join mode of the datasource you added. It needs to be a binary join (ExistsJoin).
  • alinawaz Profile Picture
    alinawaz 150 on at
    Data Entity Export failing: Cannot create a record in staging table, The record Already exists.
    Hi Jonas,
     
    Can not skip staging as their is code written on PostLoad method.

     
    And here's the index situation for entity and staging table

     
     
  • Suggested answer
    Data Entity Export failing: Cannot create a record in staging table, The record Already exists.
    You have added more information to the question, so it makes more sense now. (-:
     
    You need to change the JoinMode of HcmPositionDuration to ExistsJoin from InnerJoin. If you have more durations, it will duplicate records.
  • Suggested answer
    Data Entity Export failing: Cannot create a record in staging table, The record Already exists.
    Hi alinawaz,
     
    You can skip staging, but it's not a good solution to your problem.

    Ideally you should identify why there is an index issue (I.e. is the primary index of your staging table identical to that of the data entity etc).

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

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,572 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,792 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans