Acumatica - 在现场添加多个跟踪号

时间:2018-03-30 20:26:56

标签: customization acumatica

我正在将「追踪编号」数据字段从SOPackageDetail添加到「运费详情」选项卡上的“发票”屏幕(SO303000)。我知道它只显示一个ShipmentNbr,而这正是我用来加入这两个表但我希望所有跟踪号码,因为每个出货号码可以有多个,在现场显示而不是仅仅一。它们可以用逗号分隔字段值。这是我的代码,它只适用于一个跟踪号码。 图:

public class SOInvoiceEntry_Extension : PXGraphExtension<SOInvoiceEntry>
  {
    #region Event Handlers
protected void SOFreightDetail_RowSelecting(PXCache cache, PXRowSelectingEventArgs e, PXRowSelecting del)
    {
       if (del != null)
                del(cache, e);

            var row = (SOFreightDetail)e.Row;
            if (row == null) return;

            using (new PXConnectionScope())
                {

                    SOPackageDetail track = PXSelect<SOPackageDetail, Where<SOPackageDetail.shipmentNbr, Equal<Required<SOFreightDetail.shipmentNbr>>>>.Select(Base, row.ShipmentNbr);
                    if(track != null){
                      SOFreightDetailExt invoiceExt = row.GetExtension<SOFreightDetailExt>();
                    if (invoiceExt != null){
                       invoiceExt.TrackNumber = track.TrackNumber;

                    }  
                    }

                }

    }
    #endregion
  }

DAC扩展:

public class SOFreightDetailExt : PXCacheExtension<PX.Objects.SO.SOFreightDetail>
  {
    #region TrackNumber
    public abstract class trackNumber : PX.Data.IBqlField
    {
    }
    protected string _TrackNumber;

    [PXString()]
    [PXDefault()]
    [PXUIField(DisplayName = "Tracking Number", IsReadOnly = true)]
    public virtual string TrackNumber
    {
      get
      {
        return this._TrackNumber;
      }
      set
      {
        this._TrackNumber = value;
      }
    }
    #endregion
  }

我希望与此货件相关联的所有跟踪编号都显示在此字段中,现在它只显示一个。只有当一个货件号有多个包时才会发生这种情况。

1 个答案:

答案 0 :(得分:1)

您需要在foreach中循环记录(PXSelect)。然后,您需要将每个字符串值添加到tracknumber字段。这样的事情应该有用......

SOFreightDetailExt invoiceExt = row.GetExtension<SOFreightDetailExt>();
if(invoiceExt == null)
    return;
foreach(SOPackageDetail track in PXSelect<SOPackageDetail, Where<SOPackageDetail.shipmentNbr, Equal<Required<SOFreightDetail.shipmentNbr>>>>.Select(Base, row.ShipmentNbr))
{
    invoiceExt.TrackNumber = $"{invoiceExt.TrackNumber}, {track.TrackNumber}";
}

此外,不需要PXConnectionScope。你可以删除它。