acumaticaacumatica-kb

Modify Selector Parent Lot/ Serial Nbr to Add Filter in Materials Screen (AM300000)


Hi I want to modify the Parent Lot/ Serial Nbr in the materials screen to only show selector records where the value is greater than 0 in remaining quantity.

Selector screen

I’ve tried to modify the selector using these approaches below and it still shows selector records with remaining quantity 0.00.

 [PXMergeAttributes(Method = MergeMethod.Append)][PXRestrictor(typeof(Where<AMProdItemSplit.qtyRemaining.IsGreater<decimal0>>), "Qty Remaining is zero")]
protected virtual void _(Events.CacheAttached<AMMTran.parentLotSerialNbr> e) { }

[PXMergeAttributes(Method = MergeMethod.Replace)]
[PXDBString(INLotSerialStatus.lotSerialNbr.LENGTH, IsUnicode = true, InputMask = "")]
[PXUIField(DisplayName = "Parent Lot/Serial Nbr.", Enabled = true, FieldClass = "LotSerial")]
  [PXDefault("")]
[PXSelector(
   typeof(Search2<AMProdItemSplit.lotSerialNbr,
                InnerJoin<AMProdItem,
                    On<AMProdItem.prodOrdID, Equal<AMProdItemSplit.prodOrdID>,
                    And<AMProdItem.orderType, Equal<AMProdItemSplit.orderType>>>>,
                Where<AMProdItem.orderType, Equal<Current<AMMTran.orderType>>,
                    And<AMProdItem.prodOrdID, Equal<Current<AMMTran.prodOrdID>>,
                    And<AMProdItemSplit.qtyRemaining, Greater<decimal0>>>>>),
    typeof(AMProdItemSplit.lotSerialNbr),
    typeof(AMProdItemSplit.qty),            // Display: Total Quantity
    typeof(AMProdItemSplit.qtyComplete),    // Display: Quantity Completed
    typeof(AMProdItemSplit.qtyScrapped),    // Display: Quantity Scrapped
    typeof(AMProdItemSplit.qtyRemaining),   // Display: Quantity Remaining
    SubstituteKey = typeof(AMProdItemSplit.lotSerialNbr)
)]
protected virtual void _(Events.CacheAttached<AMMTran.parentLotSerialNbr> e)
{
}

Please let me know what I am missing, thank you!!


Solution

  • You need to use PXRestrictor attribute, and you don't need to replace all of the attributes. QtyRemaining is an unbound field, you need to use this calculation in the restrictor.

        [PXMergeAttributes(Method = MergeMethod.Merge)]  // Note the Merge instead of Replace
        [PXRestrictor(typeof(Where<SubNotLessThanZero<AMProdItemSplit.qty, 
                Add<AMProdItemSplit.qtyComplete, AMProdItemSplit.qtyScrapped>>, Greater<decimal0>>), 
            "Remaining Quantity is 0.")] 
        protected virtual void _(Events.CacheAttached<AMMTran.parentLotSerialNbr> e) { }
    

    I tested it on 24R1.