X++ job to remove duplicate address
Views (1915)
Hi,
As a part of cleanup sometimes we need to remove the duplicated address created either on customer or vendor. But manually identifying and removing them is a cumbersome task.Following job can be used to delete a specific address(identified by a location name) for a given customer.
static void AddressDeletion(Args _args)
{
LogisticsLocation location;
DirPartyLocation dirPartyLocation, partyLocation;
DirPartyLocation dirPartyLocationSecondary;
CustTable custTable;
boolean confirmDelete = true;
ttsBegin;
select firstonly custTable // Specify customer account if required
join partyLocation
where partyLocation.Party == custTable.Party
join forUpdate location
where location.RecId == partyLocation.location;
//&& location.Description == "XYZ"; // Specify location name
select firstonly RecId, Location, Party from dirPartyLocationSecondary
where dirPartyLocationSecondary.Location == partyLocation.Location && dirPartyLocationSecondary.Party != partyLocation.Party;
if(dirPartyLocationSecondary.RecId != 0)
{
select dirPartyLocation
where dirPartyLocation.RecId == partyLocation.RecId;
if (dirPartyLocation.RecId != 0)
{
// Show dialog to update parties that share this address
confirmDelete = LogisticsEntityLocationMap::showSharedAddressDialog(dirPartyLocation);
}
}
if (confirmDelete && dirPartyLocation.RecId != 0 && location.validateDelete())
{
location.delete();
}
else if (dirPartyLocation.RecId == 0 && location.validateDelete())
{
location.delete();
}
ttsCommit;
}

Like
Report
*This post is locked for comments