Hi,
What's the correct way to create addresses via code and to match standard?
for example this one inserts but doesn't update,
Also if I send an existing address, but only change locationName, then locationName doesn't get updated because of a method in the entity "resolveRemittanceAddressLocationId" which sees if everything matches an existing address by looking at lots of fields, locationName is not one of them
i thought if send a different locationName, then it will either update exsiting one or create a new address.. because in standard we are allowed to create two addresses with same details but different LocatioName
try
{
if(_address)
{
CustTable custTable = CustTable::find(_custAccount);
if(custTable)
{
DirPartyTable dirPartyTable = DirPartyTable::findRec(custTable.Party);
DirPartyLocationPostalAddressV2Entity partyAddressEntity;
partyAddressEntity.PartyNumber = dirPartyTable.PartyNumber;
partyAddressEntity.Description = _address.LocationName();
partyAddressEntity.Street = _address.Street();
partyAddressEntity.City = _address.City();
partyAddressEntity.County = _address.County();
partyAddressEntity.State = _address.State();
partyAddressEntity.CountryRegionId = _address.CountryRegionId();
partyAddressEntity.ZipCode = _address.PostCode();
partyAddressEntity.Roles = enum2Str(_roleType);
if(_logisticsLocationId)
{
partyAddressEntity.LocationId = _logisticsLocationId;
}
partyAddressEntity.insert();
LogisticsPostalAddress logisticsPostalAddress = LogisticsPostalAddress::findByLocation(partyAddressEntity.RecId);
postalAddressRecId = logisticsPostalAddress.RecId;
}
}
}
catch(Exception::Error)
{
throw error('Error');
}
//then i use postalAddressRecId to set it in SalesTable.DeliveryPostalAddress
What' the best way to handle addresses?