Get VAT Registration Number for Vendor in d365 x++

Have you ever felt lost trying to figure out how to get VAT registration numbers for vendors in D365 X++? It can be confusing, but don’t worry! In this blog post, we’re going to walk you through the whole process in simple terms. Whether you’re new to Dynamics 365 or a seasoned user, we’ve got you covered. By the end, you’ll feel confident and equipped to handle VAT registration like a pro. So, let’s get started and make VAT registration in D365 X++ a breeze!

X++ Code Display Method:

[ExtensionOf(tablestr(VendInvoiceJour))]
final class VenderVatNumber_Extension
{
    public display TaxRegistrationNumber GetVenderVat_Number()
    {
        TaxRegistration  _TaxRegistration;
        DirPartyLocation _DirPartyLocation;
        DirPartyTable    _DirPartyTable;
        VendTable        _VendTable;
        
        select REGISTRATIONNUMBER from _TaxRegistration
            join _DirPartyLocation where _TaxRegistration.DirPartyLocation == _DirPartyLocation.RecId
            && _DirPartyLocation.IsPrimary == NoYes::Yes
            join  _DirPartyTable   where _DirPartyLocation.Party == _DirPartyTable.RecId
            join _VendTable        where _DirPartyTable.RecId    == _VendTable.Party
            && _VendTable.AccountNum == this.INVOICEACCOUNT;

        return _taxRegistration.RegistrationNumber;
    }
}

SQL Query:

select REGISTRATIONNUMBER from TaxRegistration
            join DirPartyLocation on TaxRegistration.DirPartyLocation = DirPartyLocation.RecId
            AND DirPartyLocation.IsPrimary = 1
            join  DirPartyTable   on DirPartyLocation.Party = DirPartyTable.RecId
            join VendTable        on DirPartyTable.RecId    = VendTable.Party
            AND VendTable.AccountNum = 'V-0000012';

Leave a Comment

Your email address will not be published. Required fields are marked *