Hi,
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”))
{
ttsBegin;
logisticsPostalAddress.selectForUpdate(true);
logisticsPostalAddress.ValidTimeStateUpdateMode (ValidTimeStateUpdate::Correction);
logisticsPostalAddress.State = “NewState”;
logisticsPostalAddress.update();
ttsCommit;
}
}
}