在具有多个关键字段的DAC上使用带有选择器的PXFormula

时间:2018-03-02 16:56:40

标签: acumatica

我添加了两个自定义字段SOShipment.usrActualFreightCostSOFreightDetail.usrWMSFreightCost。我希望在SOFreightDetail上的UsrWMSFreightCost字段填充SOShipment上的UsrActualFreightCost中的数据。

在我看来,最简单的方法是将PXFormula与Selector一起使用。

public class SOFreightDetailExt : PXCacheExtension<PX.Objects.SO.SOFreightDetail>
{
  #region UsrWMSFreightCost
  [PXDBDecimal]
  [PXUIField(DisplayName="WMS Freight Cost")]
  [PXFormula(typeof(Selector<SOFreightDetail.shipmentNbr, SOShipmentExt.usrActualFreightCost>))]
  public virtual Decimal? UsrWMSFreightCost { get; set; }
  public abstract class usrWMSFreightCost : IBqlField { }
  #endregion
}

但是,SOShipment DAC有2个关键字段ShipmentNbrShipmentType,因此我不知道如何正确使用Selector来检索货件。

是否可以将Selector用于多个关键字段,还是需要采用不同的方法?

1 个答案:

答案 0 :(得分:0)

Selector<,>公式的第一个通用参数必须是PXSelectorAttribute的字段。 您的特定实施将无效,因为SOFreightDetail.shipmentNbr字段没有PXSelectorAttribute。 您可以尝试按PXVirtualSelectorAttribute自定义此字段,但选择器必须自行获取货件类型,例如:

[PXVirtualSelector(
    typeof(Search<SOShipment.shipmentNbr, 
        Where<SOShipment.shipmentType, Equal<Current<SOShipment.shipmentType>>>>))]

此实施仅在货件缓存的当前记录不为空时才有效,例如SOShipment是图表的主要实体。 公式也可能不支持缓存扩展。这取决于您使用的Acumatica版本。

尝试提出的解决方案并在评论中写下结果。