Job to Import Vendor/Customer Postal Address in Dynamics Ax2012

The job is for importing vendor postal address, with minor modifications it can be used for Customer also. The is also for my business scenario, so might be require some minnor modification for any other business scenario.

 static void PostalAddressCreate(Args _args)
     VendTable vendTable;
     DirParty dirParty;
     DirPartyPostalAddressView PostalAddress;
     CommaTextIo file;
     container record;
     str countyId, zipcode;
     file = new CommaTextIo("C:\\VendorPostalAddress.csv",'r');
     while (file.status() == IO_Status::Ok)
       record =;
       vendTable = VendTable::find(conPeek(record,1));
       if (vendTable.RecId)
         dirParty = DirParty::constructFromCommon(vendTable);
         PostalAddress.Street = conPeek(record,2);
         PostalAddress.BuildingCompliment = conPeek(record,3);
         PostalAddress.City = conPeek(record,4);
         PostalAddress.CountryCurrencyCode = conPeek(record,5);
         PostalAddress.CountryRegionId = conPeek(record,6);
         countyId = conPeek(record,7);
         if (Global::strStartsWith(countyId,'~'))
           countyId = strDel(countyId,1,1);
         PostalAddress.County = countyId;
         //PostalAddress.District = conPeek(record,8);
         //PostalAddress.DistrictName = conPeek(record,9);
         //PostalAddress.IsLocationOwner = conPeek(record,10);
         //PostalAddress.isocode = conPeek(record,11);
         PostalAddress.IsPrimary = conPeek(record,12);
         PostalAddress.LocationName = conPeek(record,16);
         PostalAddress.State = conPeek(record,24);
         zipcode = conPeek(record,30);
         if (Global::strStartsWith(zipcode,'~'))
           zipcode = strDel(zipcode,1,1);
         PostalAddress.ZipCode = zipcode;
         PostalAddress.ValidFrom = datetobeginUtcDateTime(1\1\2012, DateTimeUtil::getUserPreferredTimeZone()) ;
         PostalAddress.ValidTo = datetobeginUtcDateTime(1\1\2154, DateTimeUtil::getUserPreferredTimeZone()) ;
         PostalAddress.Party = vendTable.Party;
         if (!dirParty.createOrUpdatePostalAddress(PostalAddress).RecId)

One Response to Job to Import Vendor/Customer Postal Address in Dynamics Ax2012

  1. kamarudin says:

    Can I have the sample csv file for this import job

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: