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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

relationships between the two tables

(0) ShareShare
ReportReport
Posted on by 7

Goodmorning everyone
For internal company needs, I have to develop an application that will read the data directly in the AX database.
I have to make a select between these two tables
PURCHLINE and KIL_METALATTRIBUTES.

6811.Relazioni.png
If I go to see the relationships between the two:
PURCHLINE.recid == KIL_METALATTRIBUTES.ReferenceRecid
and
PURCHLINE.TableId == KIL_METALATTRIBUTES.ReferenceTableid
The problem is that the PURCHLINE.TableId column does not exist.

8267.campi.png
Without it I can't find a unique result. Do you have any idea how to help me?

*This post is locked for comments

I have the same question (0)
  • Blue Wang Profile Picture
    on at
    RE: relationships between the two tables

    Hi Marco,

    Sorry, I forgot I used F&O and you were AX.

    dextersdax.blogspot.com/.../get-table-name-from-tableid-for.html

  • Suggested answer
    Satish Panwar Profile Picture
    14,671 Moderator on at
    RE: relationships between the two tables

    Hi Marco,

    Write a simple job in AX

    tableName2Id("PurchLine").. . This will get you tableId. This is one time need and you don't need this again and it will be static in your query. See below.

    then you write your query...

    where KIL_METALATTRIBUTES.ReferenceTableid = tableid value you get from above.

    Thanks,

    Satish Panwar

    Please help verify answer(s) if they guide you in right direction so other community members can also benefit from your question with verified answer.

  • Marco Ferro Profile Picture
    7 on at
    RE: relationships between the two tables
    sorry but I still don't understand.
    Errore.png
  • Blue Wang Profile Picture
    on at
    RE: relationships between the two tables

    Hi Marco,

    You can't see the TableId field in Microsoft SQL management studio.

    Because the value of TableId is not stored in this table.

    As I mentioned above, you can select  SysTableIdView.

    5516.PNG

  • Marco Ferro Profile Picture
    7 on at
    RE: relationships between the two tables

    sorry but I can't understand how I can do to visualize that column with Microsoft SQL management studio and consequently write a query. I'm not using X ++.

  • Blue Wang Profile Picture
    on at
    RE: relationships between the two tables

    HI Marco,

    In select statement?

    axility.net/.../

  • Marco Ferro Profile Picture
    7 on at
    RE: relationships between the two tables

    How can I call it in a query?

  • Martin Dráb Profile Picture
    236,091 Most Valuable Professional on at
    RE: relationships between the two tables

    Are you aware of the fact that you won't have access to the production database in cloud? This might make your overall architecture invalid. The right approach is using web services.

    It will also allow you to benefit from all F&O business logic (including TableId field).

    An update: Oh, I see your pictures are not from F&O, so your tag "Dynamics 365 Administration" must be wrong. Ignore the part about access to database; neverthess it's true that you shouldn't access the database directly and you'd benefit from going through the application layer.

    I'll delete the invalid tag and set the product version - please pay more attention to it next time.

  • Blue Wang Profile Picture
    on at
    RE: relationships between the two tables

    Hi Marco,

    TableId is specific to each table and can be used without adding such fields, like RecId.

    If you want to see it, I add data sources through forms.(It's the same as AX.)

    0724.PNG1172.PNG


    But if you want to get the value of TableId, you can look up the system table SysTableIdView.
    To use TableId, you can create class and code.

    I hope it will help you.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#2
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

#2
Guy Terry Profile Picture

Guy Terry 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans