Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

Cannot create a relation based on table id in a data entity.

Posted on by Microsoft Employee

I'm attempting to create a new data entity to import records into a new table. The table contains a refRecId and refTableId field as it can be related to multiple different records.

I've attempted to link to another record as read only in the data entity using this refTableId and refRecId as the relation but when I attempt to build and sync this I receive errors. 

This seems to be down to the fact that although most system fields are automatically pulled onto the data source in the data entity (and the "Dynamic fields" option is greyed out and uneditable), the table Id is not. 

I cannot past the full set of errors in, because as is the case with most sql errors like this, it actually produces 50 or so errors. However, it does state "Error Invalid column name 'TABLEID'."

I can't find a standard entity using the refRecId, refTableId combination. Is this just not compatible with data entities?

*This post is locked for comments

  • Suggested answer
    PA-22040759-0 Profile Picture
    PA-22040759-0 6,194 on at
    RE: Cannot create a relation based on table id in a data entity.

    Dan, 

    Just adding to what Ievgen already answered. 

    You could populate the table name in stead, and in stead of populating the RecId you should probably populate the natural keys for these related records. 

    I have been building entities on top of a number of relations like that. It's not my idea of great fun. 

  • Suggested answer
    Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Cannot create a relation based on table id in a data entity.

    Hi Dan Griffiths,

    I think that you getting this error because TABLEID is x++ concept only. Data Entity creates SQL view under the hood and there is no "TABLEID" in underlying tables, so SQL cannot use field in a view definition that does not exist in SQL.

    I don't think that you can use read only data source here at all.  You have to populate refRecId and refTableId in x++ code, somewhere in mapEntityTODatasource method by yourself.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans