Thursday, January 21, 2016

update primary Contact Person for customer ax 2012

static void UpdatePrimaryContact(Args _args)
{
    DirPartyTable dirpartyTable;
    LogisticsElectronicAddress  electronicAddress;
    CustTable   custTable;
    DirPartyLocation        dirpartyLocation;
    LogisticsLocation      location;
    ;
    while select custTable
        //where custTable.AccountNum == "30008"
        join dirpartyLocation
         where dirpartyLocation.Party == custTable.Party
        join location where location.RecId == dirpartyLocation.Location
        && location.IsPostalAddress == false
        join electronicAddress
        where electronicAddress.Location == location.RecId
    {
        dirpartyTable.ttsbegin();
        dirpartyTable = DirPartyTable::findRec(custTable.Party,true);
        dirpartyTable.PrimaryContactPhone = electronicAddress.RecId;
        dirpartyTable.update();
        dirpartyTable.ttscommit();
    }
}

No comments:

Post a Comment

Search hierarchy for a match (TableALLGroup) X++

  Table1 ppt;  select firstonly ppt  order ItemCode, ItemRelation, AccountCode, AccountRelation where      (ppt.ItemCode == TableGroupAll::T...