Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

Relation companyInfo with OMOperatingUnit

(0) ShareShare
ReportReport
Posted on by 910

Hello ,

I'm looking how to use DirPartyTable  to get the relation between companyInfo and OMOperatingUnit 

I'm trying the bellow code but it return 0 record

SELECT * 

FROM DIRPARTYTABLE Party

    INNER JOIN MicrosoftDynamicsAx.dbo.DIRPARTYTABLE Common
		ON  Common.RECID = Party.RECID
		AND Common.INSTANCERELATIONTYPE = 2376

    LEFT OUTER JOIN MicrosoftDynamicsAx.dbo.DIRPARTYTABLE  OMOPerating 
		ON  OMOPerating.RECID	= Common.RECID
		AND OMOPerating.INSTANCERELATIONTYPE = 2377
		AND OMOPerating.RECID	= Party.RECID
    
	LEFT OUTER JOIN MicrosoftDynamicsAx.dbo.DIRPARTYTABLE CompanyInfo 
		ON   CompanyInfo.RECID = Common.RECID
		AND  CompanyInfo.INSTANCERELATIONTYPE = 41
		AND	 CompanyInfo.RECID	= Party.RECID
		AND  CompanyInfo.DATAAREA = 'USMF'


*This post is locked for comments

  • Suggested answer
    Brandon Wiese Profile Picture
    Brandon Wiese 17,788 on at
    RE: Relation companyInfo with OMOperatingUnit

    For AX 2012 R2/R3, inherited tables have been collapsed into their base table, so an OMOperatingUnit record is actually just a DirPartyTable record with an InstanceRelationType of 2377.

    The reason your query returns no results is because of the INNER JOIN to DirPartyTable with an InstanceRelationType of 2376, which is the table number for OMInternalOrganization.  There will never be any such records because that table is further inherited by OMOperatingUnit, etc.

    If you want DirPartyTable records that are actually OMOperatingUnit records, you simply have to use the following SQL.

    SELECT * 
    FROM DIRPARTYTABLE  OMOPerating 
    WHERE OMOPerating.INSTANCERELATIONTYPE = 2377;

    If you want DirPartyTable records that are actually CompanyInfo records, then use the following SQL.

    SELECT * 
    FROM DIRPARTYTABLE  CompanyInfo
    WHERE CompanyInfo.INSTANCERELATIONTYPE = 41;

    So in your example, the one record you appear to want can be fetched as follows.

    SELECT * 
    FROM DIRPARTYTABLE  CompanyInfo 
    WHERE CompanyInfo.INSTANCERELATIONTYPE = 41
      AND CompanyInfo.DATAAREA = N'USMF';

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,969 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,842 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans