Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

A valid primary key was not found on the staging table for this entity ,Entity 'Packing slip' doesn't have primary or unique key. Staging table '' needs to be altered.

(0) ShareShare
ReportReport
Posted on by 6

Hi Team,
I am getting warning while adding composite entity to export project.
I have created one header entity from CustPackingSlipJour table and another line entity from CustPackingSlipTrans. Refer below screen shot.

pastedimage1676527844742v3.png                        pastedimage1676527757950v2.png  


Created composite entity using above 2 entity.
pastedimage1676527978628v4.png

Staging table alos updated and index already created.

Geting below warning while export.
pastedimage1676528125082v6.png

Please suggest the solution.

  • Martin Dráb Profile Picture
    225,155 Moderator on at
    RE: A valid primary key was not found on the staging table for this entity ,Entity 'Packing slip' doesn't have primary or unique key. Staging table '' needs to be altered.

    That's a for different thing - a validation of the entity. The validation this thread is about (index of staging table) seems to be in DMFEntity.verifyStagingPrimaryKey().

  • Vijay Yelmame VY Profile Picture
    6 on at
    RE: A valid primary key was not found on the staging table for this entity ,Entity 'Packing slip' doesn't have primary or unique key. Staging table '' needs to be altered.

    HI Martin,
    I have debugged the code and found below from DMFQuickImportExportFormHelper::validateEntityV2() 
    pastedimage1676551408441v3.png

    pastedimage1676550958516v1.png


    It is always return false for composite entity because there is no EntityTable set for any composite entity(including standard entities).

    pastedimage1676551048677v2.png



    Thank you for all the help.



  • Martin Dráb Profile Picture
    225,155 Moderator on at
    RE: A valid primary key was not found on the staging table for this entity ,Entity 'Packing slip' doesn't have primary or unique key. Staging table '' needs to be altered.

    I'm just saying that the relation should match the entity key.

    The error is about an index on a staging table.

  • Vijay Yelmame VY Profile Picture
    6 on at
    RE: A valid primary key was not found on the staging table for this entity ,Entity 'Packing slip' doesn't have primary or unique key. Staging table '' needs to be altered.

    Hi Martin,

    I have added above mention fields in entity already.

    for header entity

    PackingSlipId

    salesId

    DeliveryDate

    CustPackingSlipJourRecId - (Primary index of CustPackingSlipJour)

    for Line entity

    PackingSlipId

    OrigSalesId

    DeliveryDate

    CustPackingSlipTransRecId (primary index of CustPackingSlipTrans)

    On staging as well it is generated. but still i am not able to understand where you exactly telling me to add the above mentioned fields.
    pastedimage1676535621001v1.pngpastedimage1676535767694v2.png

  • Martin Dráb Profile Picture
    225,155 Moderator on at
    RE: A valid primary key was not found on the staging table for this entity ,Entity 'Packing slip' doesn't have primary or unique key. Staging table '' needs to be altered.

    You keep ignoring what the error message actual talks about: indexes.

    If you want to identify the header entity by SalesId, PackingSlipId and DeliveryDate, then why don't have these fields in the entity key?

  • Vijay Yelmame VY Profile Picture
    6 on at
    RE: A valid primary key was not found on the staging table for this entity ,Entity 'Packing slip' doesn't have primary or unique key. Staging table '' needs to be altered.

    Hi Martin,
    Thank you for the information given for the entity key.

    The relation between 2 data sources is below so that I have created same relation on my line entity and the key are added on the entity are the primary key of their respective data sources.
    pastedimage1676531682858v1.png

    Now i have changed as below but getting same error. I have kept entity refresh i will check once again, but please correct me if i did anything wrong.
    pastedimage1676533304803v3.png 

    staging table
    pastedimage1676533575720v4.png

  • Martin Dráb Profile Picture
    225,155 Moderator on at
    RE: A valid primary key was not found on the staging table for this entity ,Entity 'Packing slip' doesn't have primary or unique key. Staging table '' needs to be altered.

    The error message says that there is no primary or unique key. Please look at it; you didn't mention nor show anytthing on this topic.

    Yes, it looks very strange that you define an entity key and then ignore it and use completely different fields that aren't used in any unique key. The purpose of the entity key is uniquelly identify an entity record and you need the same thing in the relation. Ambigious relations are dangerous.

  • Vijay Yelmame VY Profile Picture
    6 on at
    RE: A valid primary key was not found on the staging table for this entity ,Entity 'Packing slip' doesn't have primary or unique key. Staging table '' needs to be altered.

    Hi Martin,

    Thank you for the quick reply.

    Please find below screen shot for staging tables. 
    pastedimage1676529567102v1.png  pastedimage1676529619266v2.png

    you mean i need to use the entity key of header entity in the relation with line entity ?

  • Martin Dráb Profile Picture
    225,155 Moderator on at
    RE: A valid primary key was not found on the staging table for this entity ,Entity 'Packing slip' doesn't have primary or unique key. Staging table '' needs to be altered.

    The error message talks about staging table, but you didn't show us staging table at all, just entities.

    Also, shouldn't the relation use the entity key of the header 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

Dynamics 365 Community Update – Sep 16th

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…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

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

Overall leaderboard

Product updates

Dynamics 365 release plans