Announcements
When i want to insert new record in LogisticsPostalAddress via job , i get this error
Cannot create a record in Addresses (LogisticsPostalAddress). Insert not supported with the values specified for 'Effective:' and 'Expiration:'. New record overlaps with multiple existing records.
Anyone with some solution? it is might worth mentioning that i am entering, address, location, countryPostalCode but still this error
What value are you assigning to CountryRegionId? You can check if this value exists in Country/region under Address setup (Navigation : Organization administration > Setup > Addresses).
With code above I am getting error
Check country/region
Thank you, for this
I will do this
Have a great day
Hi,
There are a few issues here. Looking at your code, I believe you are trying to add delivery address to the sales agreement.
1. LogisticsPostalAddress has an unique key based on Location and ValidFrom fields. Additionally Location is an FK from LogisticsLocation table. So, while creating an address, you will need to create a new location record.
2. For creating addresses, the individual fields need to be populated - Street, City, Zip, State etc. The field Address ,which you are trying to populate now, is formatted from these values. If these are not mentioned, all you will be able to see in the Address field is the country name.
3. You will need to perform insert of LogisticsPostalAddress first, so that you can assign the value to AgreementHeaderDefault.DeliveryPostalAddress field. I also didn't see any code for inserting agreementHeaderDefault record in your code.
You can use this code for inserting a postalAddress record.
public LogisticsPostalAddressRecId createPostalAddress(LogisticsAddressStreet _street, LogisticsAddressCity _city, LogisticsAddressZipCodeId _zipCode, LogisticsAddressStateId _state, LogisticsAddressCountryRegionId _country, Description _addressName) { LogisticsPostalAddress logisticsPostalAddress; LogisticsPostalAddressEntity postalAddressEntity; LogisticsPostalAddressView addressView; DirPartyPostalAddressView partyAddressView; logisticsPostalAddress.Street = _street; logisticsPostalAddress.City = _city; logisticsPostalAddress.ZipCode = _zipCode; logisticsPostalAddress.State = _state; logisticsPostalAddress.CountryRegionId = _country; partyAddressView.initFromPostalAddress(logisticsPostalAddress); partyAddressView.LocationName = _addressName; postalAddressEntity = LogisticsPostalAddressEntity::construct(); addressView.initFromPartyPostalAddressView(partyAddressView); logisticsPostalAddress = postalAddressEntity.createPostalAddress(addressView); return logisticsPostalAddress.RecId; }
i am getting this error when entering from code, maybe the problem is that I am inserting sales agreement header , and logistics address in the same time?
Here is my code
info("start");
ttsBegin;
do
{
row++;
if(externalItemId!=redFlag)
{
i++;
//READING FROM EXCEL
salesAgreementId = cells.item(row, 1).value().bStr();
custAccount = cells.item(row, 2).value().bstr();
custRequisitionNumber = cells.item(row, 3).value().bStr();
effectiveDate = cells.item(row, 4).value().date();
expirationDate = cells.item(row, 5).value().date();
agreementState = AgreementState::Effective;
documentTitle = cells.item(row, 7).value().bStr();
agreementClassification = cells.item(row, 8).value().bstr();
deliveryName = cells.item(row, 9).value().bStr();
deliveryAddress = cells.item(row, 10).value().bStr();
gate = cells.item(row, 11).value().bStr();
externalItemId = cells.item(row, 12).value().bStr();
currencyCode = cells.item(row, 14).value().bstr();
//ASSIGNING VALUES
salesAgreementHeader.SalesNumberSequence = salesAgreementId;
salesAgreementHeader.CustAccount = custAccount;
salesAgreementHeaderDefault.CustomerRequisitionNumber = custRequisitionNumber;
salesAgreementHeader.DefaultAgreementLineEffectiveDate = effectiveDate;
salesAgreementHeader.DefaultAgreementLineExpirationDate = expirationDate;
salesAgreementHeader.AgreementState = AgreementState::Effective;
salesAgreementHeader.DocumentTitle = documentTitle;
agreementHeaderDeafult.DeliveryName = deliveryName;
logisticsPostalAddress.Address = deliveryAddress;
amvSalesAgreement.LogisticsGate = gate;
amvSalesAgreement.ExternalItemId = externalItemId;
agreementClassificationTable.Name = agreementClassification;
salesAgreementHeader.Currency = currencyCode;
logisticsPostalAddress.CountryRegionId="test";
logisticsPostalAddress.Location=123;
LogisticsPostalAddress.ValidFrom=myDateTime;
//INSERT
//SalesAgreementHeader
salesAgreementHeader.insert();
//SalesAgreementHeaderDefault
salesAgreementHeaderDefault.SalesAgreementHeader = salesAgreementHeader.RecId;
if(SalesAgreementHeaderDefault.validateWrite())
{
salesAgreementHeaderDefault.insert();
}
//LogisticsPostalAddress
if(logisticsPostalAddress.validateWrite())
{
logisticsPostalAddress.insert();
}
}
else
{
redFlag='empty';
}
type = cells.item(row+1, 1).value().variantType();
}
while (type != COMVariantType::VT_EMPTY);
info(strFmt("%1",i));
workbooks.close();
application.quit();
ttsCommit;
}
Hi SIwannaS,
Are you using code to insert new addresses or are you getting this error from the application? If the former is true, could you share you code here?
André Arnaud de Cal...
294,120
Super User 2025 Season 1
Martin Dráb
232,866
Most Valuable Professional
nmaenpaa
101,158
Moderator