Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Suggested answer

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?

Categories:
  • 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,274 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.

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…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 228,177 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans