Skip to main content
Answer

How to have PXSelector show default value?

  • December 21, 2021
  • 3 replies
  • 762 views

Forum|alt.badge.img+5

This is a follow up to this one: 

 

How do I make my default value for my second UOM selector appear in the selector on page load?

Here’s my DAC declaration. I also used the strategy in the referenced link to set the values for the selector dropdown on load.

I added this to try to get the default value to display...but it didn’t work:         

[PXUIField(DisplayName = "jUOM", Visibility = PXUIVisibility.SelectorVisible)]

I also tried a few other things that didn’t work. Any thoughts on how to get a Default value to appear in the Selector at load?

This part of the below referenced DAC should load the default, I think, but it doesn’t work…

        [PXDefault(typeof(Search<InventoryItem.salesUnit, Where<InventoryItem.inventoryID, Equal<Current<SOLine.inventoryID>>>>), PersistingCheck = PXPersistingCheck.Nothing)]

 

        #region juOM
        public abstract class juOM : PX.Data.BQL.BqlString.Field<juOM> { }
        protected String _jUOM;
        [INUnit(typeof(SOLine.inventoryID), DisplayName = "jUOM")]
        [PXUIField(DisplayName = "jUOM", Visibility = PXUIVisibility.SelectorVisible)]
        [PXDefault(typeof(Search<InventoryItem.salesUnit, Where<InventoryItem.inventoryID, Equal<Current<SOLine.inventoryID>>>>), PersistingCheck = PXPersistingCheck.Nothing)]

        public virtual String jUOM
        {
            get
            {
                return this._jUOM;
            }
            set
            {
                this._jUOM = value;
            }
            #endregion
        }

Best answer by Naveen Boga

Hi @rosenjon  Please use the below code to populate the jUOM. 

// To add JUOM Field at SOLine Level 

public class SOLineExt : PXCacheExtension<PX.Objects.SO.SOLine>
{
#region JUOM

[PXUIField(DisplayName = "jUOM")]
[INUnit(typeof(SOLine.inventoryID), DisplayName = "jUOM")]
[PXDefault(typeof(Search<InventoryItem.salesUnit, Where<InventoryItem.inventoryID, Equal<Current<SOLine.inventoryID>>>>), PersistingCheck = PXPersistingCheck.Nothing)]
public virtual string JUOM { get; set; }
public abstract class jUOM : PX.Data.BQL.BqlString.Field<jUOM> { }

#endregion
}




// To populate the UOM in the JUOM field

public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{

protected void _(Events.FieldUpdated<SOLine, SOLine.uOM> e)
{
SOLine row = e.Row;
if (row.UOM != null)
{
e.Cache.SetDefaultExt<SOLineExt.jUOM>(e.Row);
}
}
}

 

3 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • Answer
  • December 21, 2021

Hi @rosenjon  Please use the below code to populate the jUOM. 

// To add JUOM Field at SOLine Level 

public class SOLineExt : PXCacheExtension<PX.Objects.SO.SOLine>
{
#region JUOM

[PXUIField(DisplayName = "jUOM")]
[INUnit(typeof(SOLine.inventoryID), DisplayName = "jUOM")]
[PXDefault(typeof(Search<InventoryItem.salesUnit, Where<InventoryItem.inventoryID, Equal<Current<SOLine.inventoryID>>>>), PersistingCheck = PXPersistingCheck.Nothing)]
public virtual string JUOM { get; set; }
public abstract class jUOM : PX.Data.BQL.BqlString.Field<jUOM> { }

#endregion
}




// To populate the UOM in the JUOM field

public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{

protected void _(Events.FieldUpdated<SOLine, SOLine.uOM> e)
{
SOLine row = e.Row;
if (row.UOM != null)
{
e.Cache.SetDefaultExt<SOLineExt.jUOM>(e.Row);
}
}
}

 


Forum|alt.badge.img+5
  • Author
  • Semi-Pro III
  • December 21, 2021

Thanks Naveen. Works perfect!


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • December 21, 2021

@rosenjon  Great :) Thanks for the quick verification and sharing the update.