Get Customer Invoice Address Street
Retrieve the customer invoice address street using X++ in D365 Finance and Operations for accurate invoice address data processing.
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.

Figure: Flow of retrieving a customer's primary invoice street address.
Found this useful?
Share it with your network
Written by
Ahmad Hassan
Microsoft Dynamics 365 Finance & Operation, Technical Consultant
More about meRelated Posts
Retrieve Vendor Name, Alias, Email, Phone and Speciality
Retrieve vendor name, alias, email, phone, and speciality details using X++ in D365 Finance and Operations.
Make Document Number Mandatory on Vendor Invoice Journal Lines
Make the Document Number mandatory on Vendor Invoice Journal lines in D365 F&O using X++ validation and form customization.
Get Expiry Date from Inventory Batch
Retrieve an inventory batch expiry date in D365 F&O using X++ for batch tracking and inventory-related processing.