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

Override custom dimension value on posting sales invoice in X++

 Requirement: 1. Override custom dimension value on posting sales invoice 2.  Ledger posting type as "Cost of goods, invoiced" ...