web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Removing Duplicate Address

(1) ShareShare
ReportReport
Posted on by

Hello Experts,

In Dynamic Ax 2012 I have lots of duplicate address in the table LogisticsPosatalAddress i want to remove that duplication and update all the references. I have made the View which show me the Duplicate address with count.  Can Anybody help how to delete the duplication and update the corresponding references 

8_2D00_28_2D00_2017-7_2D00_22_2D00_44-PM.png

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    Following code can be used to delete a specific address(identified by a location name) for a given customer.

    Iterate with your view, considering records with the duplicate count greater than 2. Please test it on your test system once.

    static void AddressDeletion(Args _args)
    {
        LogisticsLocation   location;
        DirPartyLocation    dirPartyLocation, partyLocation;
        DirPartyLocation    dirPartyLocationSecondary;
        CustTable           custTable;
        boolean             confirmDelete = true;
    
        ttsBegin;
        select firstonly custTable
            join partyLocation
            where partyLocation.Party == custTable.Party
            join forUpdate location
            where location.RecId == partyLocation.location;
            //&& location.Description == "XYZ"; 
    
        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;
    }
  • Verified answer
    Community Member Profile Picture
    on at

    Thanks Chaitanya for suggesting me this option but i have 1 more query,

    See i have duplicate address in LogisticsPostalAddress Table if i delete the any of the address from that table do i need to update the references of all the field which are connected to this because this table is refereed with more the other 20 tables with the foreign key constraint

  • Verified answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    I feel update of references will be taken care by system itself.The code I provided is taken from method main of Class DirPartyPostalAddressAction which is the one that is called when we try to delete the address from CustTable/VendTable form. I tried for regular & primary address and it worked as expected. Anyway please check on test system once before actual deletion.

  • Community Member Profile Picture
    on at

    Hi Chaitanya,

    Thanks for the help sure i will test on my system and check. If the system handles the that references automatically its good as i want only primary address

    Thanking You,

    Krutish Ruparelia

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Sukrut Parab Profile Picture

Sukrut Parab 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans