0

我在通过 X++ 代码设置deliveryNamedeliveryAddress销售订单时遇到问题。(SalesTableSalesLine) 在 AX 2012 中。

这段代码将向销售订单添加一个地址,但它将该地址链接到一个客户,就像客户地址一样,然后将结果放在这两个字段中。

但是,如果我从销售订单中的“+”按钮手动创建交货地址,它会执行另一种行为。它没有将地址链接到客户,而是链接到销售订单,如何修改我的代码以使其行为如此?

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

4

1 回答 1

0

您必须在代码中设置 InitFromCustTable() 方法,这将使订单销售采用交货地址。

于 2016-09-22T21:35:04.010 回答