This is a quick overview of the main tables involved in the address book functionality of Ax2012.
In Ax2009, the integration between the address book and ‘entities’, like customers, suppliers, etc was a bit flaky. This has been tightened up in Ax2012 so that now the address book has a much more important role in maintaining basic data like customer names and addresses etc.
A few of the tables you’ll need to know about are:
Table
Description
DirPartyTable
Global address book. This will contain entries for all people and organizations
you deal with, including customers, suppliers, employees, etc.
This information is maintained across the entire organization. NB the table structure often refers to address book entries as ‘parties’. Generally other records (like customer, supplier, etc) will reference a record in this table by a field named Party.
LogisticsLocation
This is a single ‘location’ that can be attached to one or more address book entries. This is similar in principle to the old ‘Address’ table from Ax2009, that no longer exists – The main difference now being that the location header always points to an address book entry, whereas in 2009 the Address table could point to anything.
Note that this is not an address – Physical address details are stored in
LogisticsPostalAddress
LogisticsPostalAddress
A postal address, linked to a LogisticsLocation record via field Location.LogisticsElectronicAddress
‘Electronic’ address details, such as email, phone, web address etc.
Each different type of address is represented as a separate record, delineated by ‘Type’. This links to the location record.
DirPartyLocation
This table links entries in the LogisticsLocation table to an address book entry (DirPartyTable).
LogisticsLocationRole
This defines types of roles that an address are classified as, such as “Delivery”, “Invoice”, etc.
DirPartyLocationRole
Links a location role type (LogisticsLocationRole) and an address book entry (DirPartyTable)
DirPartyPostalAddressView (view)
This is a view that collates address book entries with their linked postal addressesA few of the address book tables you should know about
The following code sample shows how we could obtain the postal addresses for a customer. NB You would preferably use a view or joined queries to get this information. I’ve expanded it out to demonstrate the relationships.
static void ShowCustomerAddressBookDetails(Args _args) { CustTable custTable; DirPartyTable dirPartyTable; DirPartyLocation partyLocation; LogisticsLocation logisticsLocation; LogisticsPostalAddress postalAddress; ; custTable = custTable::find('2014'); dirPartyTable = dirPartyTable::findRec(custTable.Party); while select partyLocation where partyLocation.Party == dirPartyTable.RecId { logisticsLocation = logisticsLocation::find(partyLocation.Location); if(logisticsLocation.IsPostalAddress) { postalAddress = LogisticsPostalAddress::findByLocation(logisticsLocation.RecId); info(strFmt("%1 - %2", logisticsLocation.Description, postalAddress.CountryRegionId)); } } }
Obtaining postal addresses from a customer
And to get the email addresses:
static void ShowCustomerEmailAddresses(Args _args) { CustTable custTable; DirPartyTable dirPartyTable; DirPartyLocation partyLocation; LogisticsLocation logisticsLocation; LogisticsElectronicAddress electronicAddress; ; custTable = custTable::find('2014'); dirPartyTable = dirPartyTable::findRec(custTable.Party); while select partyLocation where partyLocation.Party == dirPartyTable.RecId { logisticsLocation = logisticsLocation::find(partyLocation.Location); while select electronicAddress where electronicAddress.Location == logisticsLocation.RecId && electronicAddress.Type == LogisticsElectronicAddressMethodType::Email { info(strFmt("%1",electronicAddress.Locator)); } } }
Obtain customer email addresses
The following code sample retrieves the phone numbers attached to a warehouse. It was added in response to a question from adiso.
static void FindPhoneNumbersAttachedToWarehouse(Args _args) { InventLocation inventLocation; LogisticsEntityPostalAddressView postalAddressView; LogisticsElectronicAddress elecAddress; LogisticsLocation contactLocation; inventLocation = inventLocation::find('11'); if(inventLocation) { while select postalAddressView where postalAddressView.Entity == inventLocation.RecId && postalAddressView.EntityType == LogisticsLocationEntityType::Warehouse { while select elecAddress where elecAddress.Type == LogisticsElectronicAddressMethodType::Phone join contactLocation where contactLocation.ParentLocation == postalAddressView.Location && contactLocation.RecId == elecAddress.Location { info(elecAddress.Locator); } } } }
Dynamics Ax Internals: Basic Address Book structure in Ax2012