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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Business Central forum

TableRelation on multiple fields

(0) ShareShare
ReportReport
Posted on by

Hi Guys

Just getting started with Dynamics 365 BC and writing my first extension. I need to create an relationship on a compound key (3 fields)

Can't find an example anywhere and can;t figure out how to do it

Can anyone point me in the right direction?


Thanks

Mark

Categories:
  • Suggested answer
    Avinash B Profile Picture
    1,455 on at

    Hi

    Please refer to the below link

    https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-set-relationships-between-tables

    Please verify the suggestion by clicking yes if it solve your problem 

    regards

    Avinash B

  • Verified answer
    Suresh Kulla Profile Picture
    50,280 Super User 2026 Season 1 on at

    Here is an example

    TableRelation = IF (Type = CONST(Item)) "Item Unit of Measure".Code WHERE("Item No." = FIELD("No."))

               ELSE

               IF (Type = CONST(Resource)) "Resource Unit of Measure".Code WHERE("Resource No." = FIELD("No."));

  • Peter Zentner Profile Picture
    390 on at

    Hi Mark,

    If you are just starting, I would suggest that you might also want to contact one of the certified development centers for some training. While it is easy to get access to the development tools, it takes time to learn actual development and, depending on what you want to do, it will take a deeper understanding of the development tools and language as well as the application to develop successfully. Getting trained by people that have worked for years with the product and language does definitely help there.

  • Suggested answer
    Community Member Profile Picture
    on at

    Thanks Ravi

    Seems like a weird syntax, but it is what it is. how would I do a join on 3 fields?

    Regards

    Mark

  • Community Member Profile Picture
    on at

    Thanks Peter

    Where would I find recommended developments centers?

    Regards

    Mark

  • Peter Zentner Profile Picture
    390 on at

    The list of ISV Development Centers. If you are an end user and only want to have some "overview training", you can also contact your partner who should be able to provide the proper training. It truly depends on how deep you want to go when developing. The deeper you go, the more training you would need.

    We can obviously assist you also here, but this will be a long and painful process, since you will not get anywhere really fast. You ask a question and will get an answer in a day or so and then get stuck at something 5 minutes later and have to repeat the process. Ideally, you either can work with someone assisting you and "learning on the job" or you get training.

    I can certainly also recommend the best course of action for you, if you want to send me a PM (I guess, you would have to first "add me as friend" and then you can send PMs), if you want to explore this further. And no, I do not work for a partner or development center, so I am not trying to sell you something.

    Peter

  • Verified answer
    Teddy Herryanto (That NAV Guy) Profile Picture
    14,306 Super User 2026 Season 1 on at

    Just extend the "where" syntax.

    Example :

    where ("Transaction No." = field ("Transaction No."), "Type" = field ("Type"), "Line No." = field ("Line No.")))

  • Community Member Profile Picture
    on at

    Thanks Teddy!

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans