Dynamics Search Engine

Tuesday, June 7, 2016

How to get postal address for customer or vendor by address type in Microsoft Dynamics AX 2012

This article explains how to get postal address for customer or vendor by address type in Microsoft Dynamics AX 2012 using X++ code.

Applied on: Dynamics AX 2012 R3 CU8.
Prerequisite: Basic Dynamics AX 2012 programming knowledge.
Target audience: AX programmers.
Assumption: You are familiar with Dynamics AX 2012.

Couple of times I received queries from my coworkers that how to get customer address or vendor address by type using standard code.

I noticed few of my coworkers used to write custom code to get postal address for customer or vendor and they struggled to find table(s) to be included in the query. It's time consuming.

In Microsoft Dynamics AX 2012 we have standard class which you can use to get address without writing any custom code.
E.g. Class DirParty has couple of useful methods for different purpose like getPostalAddress() to get the postal address, getPostalAddressByType() to get the postal address by address type etc.

The method getPostalAddressByType() gives you a complete address based on party and address type. Here you need to make a note that this method gives the address in a single string. If you need entire address information by field values, you can copy this method and write a new method where you can return the table LogisticsPostalAddress instead of Addressing EDT. Below code image you can refer to make required change. The highlighted code in red color should be removed and green color code you need to add at first and last line as shown in the image.


  1. This comment has been removed by a blog administrator.

  2. While marketing can be tricky, it is the content that makes the site important. If you provide informative content that serves the needs of your visitors, word will spread.
    usps change of address form