AX / D365FO – How to get Customer delivery address in X++

To get the Customer delivery address you can use custtable.mcrDefaultDeliveryPostalAddress() method

This example shows how to get a formatted customer delivery address from a given invoice Account

LogisticsPostalAddress logisticsPostalAddress;
str deliveryAddress;                
str deliveryName;

logisticsPostalAddress = CustTable::find(custInvoiceJour.salesTable().InvoiceAccount).mcrDefaultDeliveryPostalAddress();

deliveryAddress = logisticsPostalAddress.Street + "\n" + logisticsPostalAddress .ZipCode + " - " + logisticsPostalAddress.City + (logisticsPostalAddress.CountryRegionId ? strFmt(" (%1)", logisticsPostalAddress .CountryRegionId) : "");

deliveryName = custInvoiceJour.DeliveryName;

Leave a comment