在销售订单(表头和行)AX 2012 r2中设置DeliveryName和DeliveryAddress

时间:2013-10-24 11:18:35

标签: x++ sales dynamics-ax-2012-r2

我在通过X ++代码从销售订单设置deliveryName和deliveryAddress时遇到问题。 AX 2012中的(SalesTable和SalesLine)。

这段代码会在销售订单中添加一个地址,但它会将该地址链接到客户,如客户地址,而不是将结果放在这两个字段上。

但是,如果我从销售订单内的“+”按钮手动创建交货地址,它会执行另一种行为,因为它不会将地址链接到客户,而是链接到销售订单,该怎么做? 感谢

                    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

1 个答案:

答案 0 :(得分:0)

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