Monday 4 June 2018

Customer Contract Address Update in Ax 2012

static void Cust_contactUpdate(Args _args)
{
      LogisticsPostalAddress      address;
      CustTable                   custtable;
      DirPartyPostalAddressView   postaladdressView;
      DirParty                    dirparty;
      LogisticsLocation           location;
      DirPartyTable               dirPartyTable;
      container                   roles;
      LogisticsElectronicAddress  eAddress;
      DirPartyLocation            dirlocation;



    while  select custtable where custtable.AccountNum == "US-001"
             join  dirPartyTable where custtable.Party ==   dirPartyTable.RecId
             join  dirlocation where dirlocation.Party ==  dirPartyTable.RecId
             join  location    where location.recid == dirlocation.location
             join  eAddress where eAddress.Location == location.RecId
    {
                         //dirPartyTable.PrimaryContactEmail    == eAddress.RecId
                                             //|| dirPartyTable.PrimaryContactFax      == eAddress.RecId
                                             //|| dirPartyTable.PrimaryContactPhone    == eAddress.RecId
                                             //|| dirPartyTable.PrimaryContactTelex    == eAddress.RecId
                                             //|| dirPartyTable.PrimaryContactURL      == eAddress.RecId
                                             //|| dirPartyTable.PrimaryAddressLocation == eAddress.RecId;
    if(location.RecId)
    {
        ttsBegin;
            eAddress.Locator = "222444555";
            eAddress.selectForUpdate(true);
            eAddress.update();
        ttsCommit;
    }
    //if(address.RecId)
    //{
        //ttsBegin;
//
        //address.Street  =   "prakashnagar";
        //address.ZipCode =   "555111";
        //address.City    = "hyderabad";
        //address.CountryRegionId = "Ind";
        //address.Address = address.Street +" "+ address.ZipCode +" "+ address.City +" "+address.CountryRegionId;
        //address.selectForUpdate(true);
        //address.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction);
        //address.update();
        //ttsCommit;
//
    //}
        info(strFmt("%1---- %2",eAddress.Locator, custtable.AccountNum));
        info("Done");
    }
}

No comments:

Post a Comment