1
votes

I have added a custom drop down field in Prepare Replenishment and it always return null and not holding the selected value

enter image description here

The following are the DAC Extension code

    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
  }

For some reason, it is not even triggering field updated event

Flowing are the field property set field

enter image description here

Update 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);
    }

I have gone through the source code, INReplenishmentFilter table is declared with DB Columns, but there is not physical table in the database.

I have changed my extension field as DB Field and still, I am facing the same problem

Update 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
Regarding field updated events, you have correctly set CommitChanges=True. Can you add your event handler source code to your question, it should be declared as "void INReplenishmentFilter_UsrMonthSelection_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)" - Hugues Beauséjour

1 Answers

0
votes

Your field is declared as non-persisted (unbound):

[PXString(1)]

What happens is that the field value is held correctly in memory but when the document is invalidated it can't bring back the value from database because it wasn't persisted there in the first place.

Changing it to a bound field (PXDB instead of PX) and making sure the corresponding column do exists in the database table should resolve your issue.

[PXDBString(1, IsFixed=true)]

EDIT: Looking at your question edit, the DAC you're extending is unbound. For filter this is normal and expected. I don't understand your question in this context, the field is obviously not null in the screenshot and since you say it's not firing events how can you assert it always return null? Based on the code provided there's no scenario where you can check it's value, something is missing.