Update address displays

The below script can be used to update all address displayed, ensuring any changes to the address format are reflected in all address data.

static void UpdateAddresses(Args _args)
{
logisticsPostalAddress logisticsPostalAddress;
Addressing address;

SysOperationProgress op;

int64 icount;
;

op = new SysOperationProgress();

select count(RecId) from logisticsPostalAddress;

op.setTotal(logisticsPostalAddress.RecId);

ttsBegin;

while
select forupdate * from logisticsPostalAddress
{
op.incCount();

Address = LogisticsPostalAddress::formatAddress( logisticsPostalAddress.Street,
logisticsPostalAddress.ZipCode,
logisticsPostalAddress.City,
logisticsPostalAddress.CountryRegionId,
logisticsPostalAddress.State,
logisticsPostalAddress.County);

if(Address != logisticsPostalAddress.Address)
{
logisticsPostalAddress.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction);
logisticsPostalAddress.Address = address;
logisticsPostalAddress.update();

icount++;
}
}

ttsCommit;

info(strFmt(‘Addresses updated %1’, icount));
}

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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