X++ コードによる販売注文からの設定がうまくいきませんdeliveryName
。deliveryAddress
(SalesTable
およびSalesLine
) AX 2012 で。
このコードは販売注文に住所を追加しますが、その住所を顧客の住所などの顧客にリンクし、結果をこれら 2 つのフィールドに入力します。
しかし、Sales Order 内の「+」ボタンから手動で配送先住所を作成すると、別の動作になります。住所を顧客にリンクするのではなく、販売注文にリンクします。このように動作するようにコードを変更するにはどうすればよいですか?
lpaView.initValue();
lpaView.Street = this.getOleDBString(oleDbDataReader, #PT_DLVSTREET);
lpaView.County = this.getOleDBString(oleDbDataReader, #PT_DLVCITY);
lpaView.State = this.getOleDBString(oleDbDataReader, #PT_DLVCOUNTY);
lpaView.CountryRegionId = this.getOleDBString(oleDbDataReader, #PT_DLVSTATE);
lpaView.ZipCode = this.getOleDBString(oleDbDataReader, #PT_DLVZIPCODE);
roleContainer = [LogisticsLocationRole::findBytype(LogisticsLocationRoleType::Delivery).RecId];
if (lpaView.Street || lpaView.City || lpaView.State || lpaView.County || lpaView.ZipCode)
{
if (lpaView.County)
{
logisticsAddressCounty = LogisticsAddressCounty::findCountyCode(lpaView.CountryRegionId, lpaView.County);
if (logisticsAddressCounty)
lpaView.State = logisticsAddressCounty.StateId;
}
hasAddress = true;
dirParty = DirParty::constructFromPartyRecId(DirPartyTable::findRec(CustTable::find(salesTable.CustAccount).Party).RecId);
lpaView.Location = this.getLocationRecId(CustTable::find(salesTable.CustAccount).Party).RecId, conPeek(roleContainer, 1), lpaView.LocationName);
dirParty.createOrUpdatePostalAddress(lpaView);
addressLocation = this.getLogisticsLocationAddress(DirPartyTable::findRec(CustTable::find(salesTable.CustAccount).Party).RecId);
logisticsLocation.clear();
logisticsLocation.IsPostalAddress = NoYes::No;
logisticsLocation.ParentLocation = addressLocation.RecId;
logisticsLocation.insert();
logisticsElectronicAddress.clear();
logisticsElectronicAddress.Location = logisticsLocation.RecId;
logisticsElectronicAddress.insert();
select logisticsLocationExt where logisticsLocationExt.Location == addresslocation.RecId;
if (!logisticsLocationExt)
{
logisticsLocationExt.clear();
logisticsLocationExt.Location = addresslocation.RecId;
logisticsLocationExt.insert();
}
postalAddress = LogisticsPostalAddress::findByLocation(logisticsLocation.ParentLocation);
}
salesTable.DeliveryPostalAddress = postalAddress.RecId;
zfds