自定义字段值始终在Prepare Replenishment中返回null

时间:2018-03-27 09:10:36

标签: acumatica

我在Prepare Replenishment中添加了一个自定义下拉字段,它总是返回null而不是保持所选值

enter image description here

以下是DAC扩展代码

    public class INReplenishmentFilterExt : PXCacheExtension<PX.Objects.IN.INReplenishmentFilter>
  {
    #region UsrMonthSelection
    [PXString(1)]
    [PXUIField(DisplayName="Months")]
    [PXStringList(new[] { "1", "2", "3", "4", "5", "6" },
                    new[] { "One", "Two", "Three", "Four", "Five", "Six" })]
    public virtual string UsrMonthSelection { get; set; }
    public abstract class usrMonthSelection : IBqlField { }
    #endregion
  }

由于某种原因,它甚至没有触发字段更新事件

Flowing是字段属性集字段

enter image description here

更新1

protected void INReplenishmentFilter_UsrMonthSelection_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
    {
        var row = (INReplenishmentFilter)e.Row;
        INReplenishmentFilterExt extn = cache.GetExtension<INReplenishmentFilterExt>(row);
        string sOption = extn.UsrMonthSelection;
        monthsel = Convert.ToInt32(sOption);
    }

我已经浏览了源代码,使用DB Columns声明了INReplenishmentFilter表,但数据库中没有物理表。

我已将我的扩展字段更改为DB字段,但我仍面临同样的问题

更新2

protected void INReplenishmentItem_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected InvokeBaseHandler)
{
    if (InvokeBaseHandler != null)
        InvokeBaseHandler(cache, e);
    var row = (INReplenishmentItem)e.Row;
    if (row == null) return;

    INReplenishmentFilterExt extn = PXCache<INReplenishmentFilter>.GetExtension<INReplenishmentFilterExt>(Base.Filter.Current);
    //extn.UsrMonthSelection - This value return null value customfield is selected after populating the replinishment grid.
    /monthsel - This value always 0
    monthsel = Convert.ToInt32(extn.UsrMonthSelection);
    PXUIFieldAttribute.SetVisible<INReplenishmentExtn.usrSoQtyMonthOne>(cache, null, monthsel > 0);
    PXUIFieldAttribute.SetVisible<INReplenishmentExtn.usrSoQtyMonthTwo>(cache, null, monthsel > 1);
    PXUIFieldAttribute.SetVisible<INReplenishmentExtn.usrSoQtyMonthThree>(cache, null, monthsel > 2);
    PXUIFieldAttribute.SetVisible<INReplenishmentExtn.usrSoQtyMonthFour>(cache, null, monthsel > 3);
    PXUIFieldAttribute.SetVisible<INReplenishmentExtn.usrSoQtyMonthFive>(cache, null, monthsel > 4);
    PXUIFieldAttribute.SetVisible<INReplenishmentExtn.usrSoQtyMonthSix>(cache, null, monthsel > 5);
}

1 个答案:

答案 0 :(得分:0)

您的字段被声明为非持久(未绑定):

[PXString(1)]

字段值在内存中保存得正确,但是当文档无效时,它无法从数据库中恢复该值,因为它首先不会保留在那里。

将其更改为绑定字段(PXDB而不是PX)并确保数据库表中存在相应的列应解决您的问题。

[PXDBString(1, IsFixed=true)]

修改 查看您的问题编辑,您正在扩展的DAC是未绑定的。对于过滤器,这是正常的和预期的。在这种情况下我不明白你的问题,截图中的字段显然不是空的,因为你说它没有触发事件你怎么断言它总是返回null?根据提供的代码,没有可以检查它的价值的情况,缺少某些东西。