NumberSeq numberSeq;
ContactPersonSyncEntity contactPersonEntity;
container roleContainer;
// Generate new Contact Person ID
ttsbegin;
numberSeq = NumberSeq::newGetNum(ContactPerson::numRefContactPersonId());
contactPerson.ContactPersonId = numberSeq.num();
numberSeq.used();
ttscommit;
// Create Contact Person record
ttsbegin;
contactPerson.CustAccount = 'Test001';
contactPersonEntity = ContactPersonSyncEntity::construct(contactPerson);
contactPersonEntity.parmContactPersonId(contactPerson.ContactPersonId);
contactPersonEntity.parmFirstName("FirstName");
contactPersonEntity.parmLastName('Last name');
contactPersonEntity.parmLanguageId('US-EN');
contactPersonEntity.write();
ttscommit;
// create postal address for contact person
DirPartyPostalAddressView postalAddressView;
LogisticsPostalAddress logisticsPostalAddress;
LogisticsLocation logisticsLocation;
LogisticsAddressStreet street;
DirParty dirParty = DirParty::constructFromCommon(contactPerson);
DirPartyLocation dirPartyLocation;
boolean ret = true;
DirPartyPostalAddressView partyPostalAddressView;
ttsbegin;
logisticsLocation.clear();
logisticsLocation.Description = 'test desc';
logisticsLocation.IsPostalAddress = true;
logisticsLocation.LocationId = '001234';
logisticsLocation.insert();
logisticsPostalAddress = LogisticsPostalAddress::findByLocation(logisticsLocation.RecId, true);
if(!logisticsPostalAddress.RecId)
{
logisticsPostalAddress.clear();
}
logisticsPostalAddress.CountryRegionId = 'US';
logisticsPostalAddress.State = 'Test state';
logisticsPostalAddress.County = 'US';
logisticsPostalAddress.City = 'test city';
logisticsPostalAddress.ZipCode = '989238';
logisticsPostalAddress.Street = 'test street';
logisticsPostalAddress.Location = logisticsLocation.RecId;
postalAddressView.initFromPostalAddress(logisticsPostalAddress);
postalAddressView.LocationName = 'Business';
postalAddressView.Party = contactPerson.Party;
postalAddressView.IsPrimary = true;
postalAddressView.ProArIsCreatedByIntegration = true;
partyPostalAddressView = DirParty.createOrUpdatePostalAddress(postalAddressView,LogisticsLocationRole::findByName('Business').RecId);
ttscommit;