Solved

How to have PXSelector show default value?

  • 21 December 2021
  • 3 replies
  • 551 views

Userlevel 6
Badge +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
        }

icon

Best answer by Naveen Boga 21 December 2021, 08:14

View original

3 replies

Userlevel 7
Badge +17

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

 

Userlevel 6
Badge +5

Thanks Naveen. Works perfect!

Userlevel 7
Badge +17

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

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved