Monday 24 November 2014

code to create a new postal address for a existing customer in Ax 2012

static void Job1(Args _args)
{
  LogisticsElectronicAddress    LogisticsElectronicAddress;
  CustTable                     CustTable;
  DirPartyContactInfoView       contactInfo;
  DirPartyPostalAddressView     postalAddress;
  DirParty                        dirParty;
  DirPartyPostalAddressView       dirPartyPostalAddressView;
  DirPartyContactInfoView         dirPartyContactInfo;

  CustTable = CustTable::find("LOL-000002");
  info(strfmt("%1",CustTable.email()));
  info(strfmt("%1",CustTable.address()));
  ttsBegin;

  try
  {


   dirParty = DirParty::constructFromCommon(CustTable);
   dirPartyPostalAddressView.LocationName      ='HeadQuarters ';
   dirPartyPostalAddressView.City              ='chennai';
   dirPartyPostalAddressView.Street            ='4th Avenue';
   dirPartyPostalAddressView.StreetNumber      ='18';
   dirPartyPostalAddressView.CountryRegionId   ='IND';
  // dirPartyPostalAddressView.State             ='SP';
   dirParty.createOrUpdatePostalAddress(dirPartyPostalAddressView);

    dirPartyContactInfo.LocationName    ='SouthStreet Contact Phone';
    dirPartyContactInfo.Locator         ='9600147034';
    dirPartyContactInfo.Type            = LogisticsElectronicAddressMethodType::Phone;
    dirPartyContactInfo.IsPrimary       = NoYes::Yes;

        // Fill Contacts
     dirParty.createOrUpdateContactInfo(dirPartyContactInfo);
     info("address created ");

        // Marks the end of transaction.

      ttsCommit;
    }

    catch(Exception::Error)
    {
       ttsAbort;
       throw Exception::Error;
    }


}

No comments:

Post a Comment

intercompany PO multiple product receipt by x++

public void processStampICPO(PackingSlipId _deliveryNote,                             Transdate _deliverydate,                             ...