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 ');
File.infielddelimiter (', ');
while (file.status () = = Io_status::ok)
{
Record = File.read ();
VendTable = Vendtable::find (Conpeek (record,1));
if (VENDTABLE.RECID)
{
try{
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)
{
info (vendtable.accountnum);
}
}
catch (Exception::error)
{
info (vendtable.accountnum);
}
}
}
}
Job to Import Vendor/customer Postal Address in Dynamics Ax2012