Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Data entity extension for Vendor party base type

(0) ShareShare
ReportReport
Posted on by 199

We've created a data entity to provide details of vendor transactions, and one of the fields required on the data entity is the vendor type (organisation or person). Party base type doesn't seem to be a database field (happy to be told I'm missing something), so we've ended up with a computed field in the data entity that feels more clunky than I'd like. Other than better use of SysComputedColumn to construct the outer joins, anyone have a smoother way to get this please?

public class CUSVendorTransactionEntity extends common
{
    public static server str VendorPartyType()
    {
        DataEntityName  dataEntityName= tablestr(CUSVendorTransactionEntity);
        str             AccountNum;
        str             qry;

        accountNum = SysComputedColumn::returnField(DataEntityName, identifierstr(VendTrans), fieldstr(VendTrans, AccountNum));

        qry = strFmt("select case when dpn.[recid] is null then 'Organisation' else 'Person' end from [VENDTABLE] vt inner join [DIRPARTYTABLE] dpt on vt.[PARTY] = dpt.[RECID] left outer join [DIRPERSONNAME] dpn on dpt.[RECID] = dpn.[PERSON] where vt.[ACCOUNTNUM] = %1", accountNum);

        return qry;
    }

}

  • Rich Profile Picture
    199 on at
    RE: Data entity extension for Vendor party base type

    Thanks André. Good reminder that there's normally a precedent somewhere.

  • Verified answer
    André Arnaud de Calavon Profile Picture
    283,860 Test role Public on at
    RE: Data entity extension for Vendor party base type

    Hi Rich,

    The party type is indeed not a database field. It is using an instance table ID as part of the table inheritance. You can consider using the same logic as Microsoft used themselves on the DirPartyBaseEntity:

    private static str partyType()
        {
            /*********************************************
            The following is an example of what the query string will look like, table id's may vary:
            
        CASE DirPartyTable.InstanceRelationType
            WHEN 11840 THEN 'Person'
            WHEN 1910  THEN 'Organization'
            WHEN 8099  THEN 'LegalEntity'
            WHEN 7525  THEN 'OperatingUnit'
            WHEN 6237  THEN 'Team'
            ELSE ''
            END
            *********************************************/
            Map partyTypesMap = DirUtility::getPartyTypeNames();
    
            return SysComputedColumn::switch(
                SysComputedColumn::comparisonField(tableStr(DirPartyBaseEntity), tableStr(DirPartyTable), fieldStr(DirPartyTable, InstanceRelationType)),
                partyTypesMap,
                SysComputedColumn::returnLiteral(''));
        }
    

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

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…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
PJ JohnPaul Profile Picture

PJ JohnPaul 100

5
#2
Jahanvi Profile Picture

Jahanvi

2
Overall Leaderboard

Product updates

Dynamics 365 release plans