What is going on behind the scenes, is the AddressMap is being used to correctly format the address.
The Address.address, CustTable.address, VendTable.address, etc. fields should not be manually filled in. They should not have data dumped into them either. It is a derived/built field that depends on the country code and each individual format.
This is important when you deal with international customers and customs. Customs for European countries, for example, can be very picky with documents. If the address is even slightly malformed, I've seen product get held for up to a month, and sometimes it's seized...all for a silly address error.
Here is a job I wrote that can be adapted to automate the process of building addresses using AddressMap. Right now, it lets you pick a customer that you want to correct the addresses for, then displays a before/after of the addresses.
Enjoy! As always, comments are welcome!
static void updateCustAddress(Args _args) { Dialog dialog; DialogField field; CustTable custTable; Address address; DirPartyAddressRelationship dpar; DirPartyAddressRelationshipMapping dparm; AccountNum accountNum; ; dialog = new Dialog("Build customer address"); dialog.addText("Select your customer to update:"); field = dialog.addField(typeid(CustAccount)); dialog.run(); if(dialog.closedOk()) { accountNum = field.value(); if (CustTable::exist(accountNum)) { ttsbegin; while select forupdate address join dpar join dparm join custTable where custTable.AccountNum == accountNum && custTable.PartyId == dpar.PartyId && dpar.RecId == dparm.PartyAddressRelationshipRecId && dparm.RefCompanyId == curExt() && dparm.AddressRecId == address.RecId { info(strfmt("Type %1 - before:", address.type)); info(strFmt(">%1<", address.Address)); address.AddressMap::setAddress(); address.update(); info(strfmt("Type %1 - after:", address.type)); info(strFmt("<%1>", address.Address)); } ttscommit; } else { info("Invalid Account"); } } info("Done"); }