Skip to main content
X++ Development · · 2 min read

Get Customer Invoice Address Street

 Retrieve the customer invoice address street using X++ in D365 Finance and Operations for accurate invoice address data processing. 

A

Ahmad Hassan

Dynamics 365 F&O Consultant

Share
Get Customer Invoice Address Street

This X++ method retrieves the street address for a specified customer account.
It identifies the customer and related party record, then finds the primary invoice address through DirPartyLocation and LogisticsPostalAddress.
The method returns the corresponding Street value from the postal address record.

X++ Code

public static Name getStreet(CustAccount _custNo)

{

    CustTable               custTable;

    DirPartyTable           dirPartyTable;

    DirPartyLocation        dirPartyLocation;

    LogisticsPostalAddress  logisticsPostalAddress;

    custTable = CustTable::find(_custNo);

    select firstonly dirPartyTable

        where dirPartyTable.RecId == custTable.Party;

    //select * from dirPartyLocation

    //    where dirPartyLocation.Party == custTable.Party;

    //&& dirPartyLocation.IsPrimary  == NoYes::No

    select firstonly dirPartyLocation

            where dirPartyLocation.PARTY == CUSTTABLE.PARTY

            join LogisticsPostalAddress

            where LogisticsPostalAddress.LOCATION == dirPartyTable.PrimaryAddressLocation

            && LogisticsPostalAddress.LOCATION == dirPartyLocation.LOCATION

            && dirPartyLocation.IsPrimary == NoYes::Yes

            && dirPartyLocation.PostalAddressRoles == #Invoice;

    //join logisticsPostalAddress

    //where logisticsPostalAddress.Location == dirPartyTable.PrimaryAddressLocation

    //   && logisticsPostalAddress.Location == dirPartyLocation.Location;

    //&& dirPartyLocation.PostalAddressRoles == 'Invoice';

    //select * from logisticsPostalAddress

    //    where logisticsPostalAddress.Location == dirPartyTable.PrimaryAddressLocation

    //       && logisticsPostalAddress.Location == dirPartyLocation.Location;

    return logisticsPostalAddress.Street;

}

Process Flow

The method receives a customer account and retrieves the corresponding CustTable record.

It then identifies the related DirPartyTable record through the customer's Party reference.

The primary invoice DirPartyLocation and matching LogisticsPostalAddress are selected using the address location and invoice role.

Finally, the method returns the Street value from the selected postal address.

dab07b2d-7092-4678-b770-2dc461db0ced.png

Figure: Flow of retrieving a customer's primary invoice street address.

Found this useful?

Share it with your network

A

Written by

Ahmad Hassan

Microsoft Dynamics 365 Finance & Operation, Technical Consultant

More about me

Related Posts

Comments

Leave a comment