X++ job to move address from one party to another party
Views (1306)
Hi,
Often we come across a requirement to move address(es) either from one customer to another customer (or) from one vendor to another vendor.Following job helps us to serve this purpose and inplace of custTable, vendTable can be subsituted to make it work for vendors.
static void AddressChange(Args _args)
{
CustTable custTable, toCustomer;
DirPartyTable dirPartyTable, toParty;
LogisticsPostalAddress postalAddress;
DirPartyLocation dirPartyLocation, toPartyLocation;
LogisticsLocation logisticsLocation;
while select custTable
where custTable.AccountNum == "123" // From customer
join dirPartyTable
where custTable.Party == dirPartyTable.RecId
join dirPartyLocation
where dirPartyLocation.Party == dirPartyTable.RecId
&& dirPartyLocation.IsPostalAddress == true
//&& dirPartyLocation.IsPrimary == true
join logisticsLocation
where logisticsLocation.RecId == dirPartyLocation.Location
&& logisticsLocation.Description == "Name" // Address Name or description
{
select custTable
where custTable.AccountNum == "345"; // To customer
ttsBegin;
dirPartyLocation.selectForUpdate(true);
dirPartyLocation.Party = custTable.Party;
dirPartyLocation.IsPrimary = false;
dirPartyLocation.update();
ttsCommit;
}
}

Like
Report
*This post is locked for comments