Skip to main content
Answer

Custom field using [Inventory] attribute but not as a DB field

  • August 24, 2023
  • 2 replies
  • 87 views

Joe Schmucker
Captain II
Forum|alt.badge.img+3

I want to create a custom field using the [Inventory] attribute so that I get the selector and it is all sorted out for me.  I don’t want it to be PXDBInt.  I want it to be a virtual field of type PXInt.

        #region UsrModEquipTempID
        [Inventory]
        [PXUIField(DisplayName = "Model Equipment")]
        public int? UsrModEquipTempID { get; set; }
        public abstract class usrModEquipTempID : PX.Data.BQL.BqlInt.Field<usrModEquipTempID> { }
        #endregion

If I put [PXInt], it causes a compiler error.  

How can I do that?

 

 

Best answer by Naveen Boga

Hi @Joe Schmucker  Yes, [InventoryID] will not work with unbound field fields.

You can your DAC like below.

 

       #region FirstItem

[PXInt()]
[PXSelector(typeof(Search<InventoryItem.inventoryID, Where<InventoryItem.stkItem, Equal<True>,
And<InventoryItem.itemStatus, Equal<AMIConstants.ActiveStatus>>>>), new Type[] { typeof(InventoryItem.inventoryCD), typeof(InventoryItem.descr) }, SubstituteKey = typeof(InventoryItem.inventoryCD))]
[PXUIField(DisplayName = "Select Item", Required = true)]
public virtual int? FirstItem { get; set; }
public abstract class firstItem : IBqlField { }

#endregion

 

2 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • Answer
  • August 24, 2023

Hi @Joe Schmucker  Yes, [InventoryID] will not work with unbound field fields.

You can your DAC like below.

 

       #region FirstItem

[PXInt()]
[PXSelector(typeof(Search<InventoryItem.inventoryID, Where<InventoryItem.stkItem, Equal<True>,
And<InventoryItem.itemStatus, Equal<AMIConstants.ActiveStatus>>>>), new Type[] { typeof(InventoryItem.inventoryCD), typeof(InventoryItem.descr) }, SubstituteKey = typeof(InventoryItem.inventoryCD))]
[PXUIField(DisplayName = "Select Item", Required = true)]
public virtual int? FirstItem { get; set; }
public abstract class firstItem : IBqlField { }

#endregion

 


Joe Schmucker
Captain II
Forum|alt.badge.img+3
  • Author
  • Captain II
  • August 24, 2023

@Naveen Boga Thank you so much for giving me the code!