D365FFO – AX – Updating Vendor Address using X++


Vendor address state value can be retrieved from tables VendTable, DirPartyTable, DirPartyLocation, LogisticsLocation and LogisticsPostalAddress (or) through the view DirPartyPostalAddressView(mentioned in the blogs suggested by Vilmos)

You can use the following job(query) to get the data and to update the state:
static void VendorState(Args _args)
VendTable vendTable;
DirPartyTable dirPartyTable;
DirPartyLocation dirPartyLocation;
LogisticsLocation logisticsLocation;
LogisticsPostalAddress logisticsPostalAddress;
LogisticsAddressState LogisticsAddressState;

while select vendTable
where vendTable.AccountNum == “Vend1” // Vendor
join dirPartyTable
where vendTable.Party == dirPartyTable.RecId
join dirPartyLocation
where dirPartyLocation.Party == dirPartyTable.RecId
&& dirPartyLocation.IsPostalAddress == true
//&& dirPartyLocation.IsPrimary == true // To get primary address
join logisticsLocation
where logisticsLocation.RecId == dirPartyLocation.Location
&& logisticsLocation.Description == “AddressDescription” // Address description
join logisticsPostalAddress
where logisticsPostalAddress.Location == dirPartyLocation.Location
// Older state
info(strFmt(“State: %1”, logisticsPostalAddress.State));

// Newer state – Check on the new state
if (LogisticsAddressState::exist(logisticsPostalAddress.CountryRegionId, “NewState”))
logisticsPostalAddress.ValidTimeStateUpdateMode (ValidTimeStateUpdate::Correction);
logisticsPostalAddress.State = “NewState”;


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s