Announcements
No record found.
Hello guys,
I'm working in a project that require me to find the relation between two random tables
I'm using some sys methods , right now, I can find the direct relation between two tables, but some times the tables have indirect relation which is kind problematic.
I did some google about it, and I didn't find much.
I would like something like this link, but it didn't work well for mehttps://lalitoberoi.wordpress.com/2014/08/29/how-to-find-relation-between-two-tables-from-x-code/
Do you guys know any approach for this?
Thanks,
Hi bois0155,
Are these custom tables or standard D365 tables?
The table would be any table in the system, so could be standard or custom I just need to get the relation path between two tables
You could use the DictRelation and DictTable classes.
Please try to loop through all table relations with the following codes.
static void findRelatedFieldId(TableId _tableIda,TableId _tableIdb) { DictTable dictTable = new DictTable(_tableIda); int i,j; DictRelation dictRelation; TableId externId = _tableIdb; IndexId indexId; ; dictRelation = new DictRelation(dictTable.id()); // Search relations for (i = 1; i <= dictTable.relationCnt(); i ) { dictRelation.loadNameRelation(dictTable.relation(i)); // If it is a 'relation' then you use externTable(), but for extended data types you use table() if ( dictRelation.externTable()== externId) { for (j =1; j <= dictRelation.lines(); j ) { info(strfmt("%1", dictRelation.lineExternTableValue(j))); info(fieldid2name(dictRelation.externTable(),dictRelation.lineExternTableValue(j))); } } } }
Hi bois0155, can you share any details about the underlying business requirement? What would this functionality be used for?
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.
Congratulations to our 2026 Super Stars!
Thanks to all of our 2025 Community Spotlight stars!
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Giorgio Bonacorsi 617
André Arnaud de Cal... 461 Super User 2026 Season 1
Syed Haris Shah 298 Super User 2026 Season 1