Showing posts with label Customers Address Merging in Ax 2012. Show all posts
Showing posts with label Customers Address Merging in Ax 2012. Show all posts

Monday, 13 June 2016

Vendors Merging and Customers Address Merging in Ax 2012

CustomerAddress Merge
static void Raj_CustomerAdressMerge(Args _args)
{
    CustTable custTable;
    DirParty dirParty;
    DirPartyPostalAddressView PostalAddress, PostalAddressDest;
    ;

    custTable = CustTable::find('R001'); //From Customer Address

     select PostalAddress
        where PostalAddress.Party == CustTable.Party;
   
        buf2Buf(PostalAddress, PostalAddressDest);
        PostalAddressDest.Party = CustTable::find('R002').Party; //To customer Address
        PostalAddressDest.IsPrimary = NoYes::No;
        PostalAddressDest.LocationName =  PostalAddress.LocationName;
        dirParty = DirParty::constructFromCommon(custTable);
        dirParty.createOrUpdatePostalAddress(PostalAddressDest);

}



VendorsMerging

static void VendAccountMerge(Args _args)
{
      VendTable            vendTable;
      VendTable            vendTableDelete;
       PurchJournalAutoSummary           jourSummary;
      #define.vend('14063')
      #define.vendDelete('14437')
     ;

     ttsbegin;
    delete_from jourSummary where jourSummary.VendAccount == #vendDelete;
    select firstonly forupdate vendTableDelete where vendTableDelete.AccountNum == #vendDelete;
    select firstonly forupdate vendTable where vendTable.AccountNum == #vend;
    
    vendTableDelete.merge(vendTable);
    vendTable.doUpdate();
   //vendTableDelete.doDelete();
     ttscommit;

}