进入采购订单条目时,如何从供应商位置记录中获取VShipTermsID?

时间:2019-03-28 21:30:29

标签: acumatica

我们的客户要求我们将运输条款字段添加到PO Entry Screen。查看源代码,似乎在POOrder_VendorLocaition_FieldUpdated事件中设置了“通过”字段。

    protected virtual void POOrder_VendorLocationID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
    {
        Location current = (Location)this.location.Current;
        POOrder row = (POOrder)e.Row;
        if (current == null || (current.BAccountID != row.VendorID || current.LocationID != row.VendorLocationID))
        {
            current = this.location.Select();
            this.location.Current = current;
        }
        ...
        sender.SetDefaultExt<POOrder.shipVia>(e.Row);
        ...
    }

当我创建一个POOrderEntry_Extension并编写一个POOrder_VendorLocation_FieldUpdated事件时(没有sender.SetDefaultExt行,它的验证失败:

\ App_RuntimeCode \ POOrderEntry.cs(38):错误CS1061:“ PX.Objects.PO.POOrderEntry_Extension”不包含“位置”的定义,并且没有扩展方法“位置”接受类型为“ PX”的第一个参数。可以找到Objects.PO.POOrderEntry_Extension(您是否缺少using指令或程序集引用?)

我认为,一旦我可以查询VShipTermsID字段,就可以在PO中设置UsrVShipTermsID字段。我尝试搜索适当的using指令,并尝试进入供应商记录和位置记录。任何指导将不胜感激。

这是UsrVShipTermsID字段的DAC扩展。

[PXDBString(10)]
[PXSelector(typeof(
   Search<ShipTerms.shipTermsID>),
   DescriptionField = typeof(ShipTerms.description))]
[PXUIField(DisplayName = "Shipping Terms")]

这是完整的POOrderEntry_Extension

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using PX.Common;
using PX.Data;
using PX.Objects.GL;
using PX.Objects.CM;
using PX.Objects.CS;
using PX.Objects.CR;
using PX.Objects.TX;
using PX.Objects.IN;
using PX.Objects.EP;
using PX.Objects.AP;
using PX.Objects.AR;
using PX.Objects.SO;
using PX.TM;
using SOOrder = PX.Objects.SO.SOOrder;
using SOLine = PX.Objects.SO.SOLine;
using PX.CS.Contracts.Interfaces;
using PX.Data.DependencyInjection;
using PX.LicensePolicy;
using PX.Objects.PM;
using CRLocation = PX.Objects.CR.Standalone.Location;
using PX.Objects.AP.MigrationMode;
using PX.Objects.Common;
using PX.Objects.Common.Discount;
using PX.Objects;
using PX.Objects.PO;
using PX.Objects.AP.Locations;

namespace PX.Objects.PO
{
  public class POOrderEntry_Extension : PXGraphExtension<POOrderEntry>
  {
    #region Event Handlers
    protected virtual void POOrder_VendorLocationID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
    {
      Location current = (Location)Base.location.Current;
      POOrder row = (POOrder)e.Row;
      if (current == null || (current.BAccountID != row.VendorID || current.LocationID != row.VendorLocationID))
      {
        current = this.location.Select();
        this.location.Current = current;
      }
      //sender.SetDefaultExt<POOrder.shipVia>(e.Row);
    }
    #endregion
  }
}

最初,我打算从PO到供应商再到位置,但是在尝试查找位置记录时迷路了。具有相同的using指令。

protected virtual void POOrder_VendorID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
{
  var row = e.Row as POOrder;
  if (row.VendorID != null)
  {
    var vendor = PXSelectorAttribute.Select<POOrder.vendorID>(sender, row) as BAccount;
    if (vendor != null)
    {
      //var poorderExt = row.GetExtension<POOrderExt>();
      //poorderExt.UsrVShipTermsID = vendor.VShipTermsID;
      //sender.SetDefaultExt<POOrderExt.usrVShipTermsID>(e.Row);
      //sender.SetValueExt<POOrderExt.usrVShipTermsID>(row, VendorClass.shipTermsID);
      //poorderExt.UsrVShipTermsID = VendorClass.vendor.GetValue<VendorClass.shipTermsID>(VendorClass.vendor);
    }
  }
}

2 个答案:

答案 0 :(得分:0)

如果需要从扩展名访问基本Graph的属性或方法,请使用Base而不是此。例如,基础图中的代码行

Location current = (Location)this.location.Current;

将会

Location current = (Location)Base.location.Current;

在图形扩展名中。

答案 1 :(得分:0)

一位同事提供了答案。

protected void POOrder_VendorLocationID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
{
  POOrder row = (POOrder)e.Row;
  if (row == null) 
    return;
  POOrderExt rowExt = PXCache<POOrder>.GetExtension<POOrderExt>(row);
  {
    //retrieve LocVend Data
    LocationExtAddress location = PXSelect<LocationExtAddress,
       Where<LocationExtAddress.bAccountID, Equal<Current<POOrder.vendorID>>,
       And<LocationExtAddress.locationID, Equal<Current<POOrder.vendorLocationID>>>>>.Select(Base, row);
    rowExt.UsrVShipTermsID = location.VShipTermsID;
  }
}

感谢支持和帮助。