I am facing an issue with a customization on the Receive and Put Away screen related to automatically triggering the Set Qty action, and I would appreciate your guidance.
Screen
Receive and Put Away (PO302020)
Issue Description
I have implemented custom logic to automatically trigger the Set Qty action after scanning an item.
In Receive mode, the functionality works as expected.
After scanning the item, the Set Qty state is triggered automatically, and the system prompts the user to enter the quantity.
In Put Away mode, the same logic does not work.
Expected Behavior
In Put Away mode, after scanning the item and location as per flow, the system should automatically trigger the Set Qty action and prompt the user to enter the quantity.
Customization Code Reference
using System;
using System.Collections;
using PX.Data;
using PX.BarcodeProcessing;
using PX.Objects.IN;
using PX.Objects.PO.WMS;
namespace PX.Objects.PO.WMS
{
public class ReceivePutAwayExt_ASetQtyExt
: PXGraphExtension<ReceivePutAway, ReceivePutAway.Host>
{
public static bool IsActive() => true;
public class AutoQtyState : ReceivePutAway.EntityState<decimal?>
{
public BarcodeQtySupport<ReceivePutAway, ReceivePutAway.Host> QtyBase =>
BarcodeQtySupport<ReceivePutAway, ReceivePutAway.Host>.GetSelf(Basis);
public override string Code => "AUTOQTY";
protected override string StatePrompt => "Enter the quantity.";
protected override decimal? GetByBarcode(string barcode)
{
if (decimal.TryParse(barcode, out decimal qty))
return qty;
return 1m;
}
protected override void Apply(decimal? value)
{
QtyBase.QtySetter.WithEventFiring
.Set(x => x.Qty, value ?? 1m);
}
}
[PXOverride]
public virtual ScanMode<ReceivePutAway> DecorateScanMode(
ScanMode<ReceivePutAway> original,
Func<ScanMode<ReceivePutAway>, ScanMode<ReceivePutAway>> baseMethod)
{
var mode = baseMethod(original);
// RECEIVE MODE – WORKING AS EXPECTED
if (mode is ReceivePutAway.ReceiveMode receiveMode)
{
receiveMode.Intercept.CreateStates.ByAppend(
b => new[] { new AutoQtyState() }
);
receiveMode.Intercept.CreateTransitions.ByReplace(basis =>
Base1.StateFlow(flow => flow
.From<ReceivePutAway.RefNbrState<POReceipt>>()
.NextTo<ReceivePutAway.InventoryItemState>()
.NextTo<AutoQtyState>()
.NextTo<ReceivePutAway.LocationState>()
.NextTo<ReceivePutAway.LotSerialState>()
.NextTo<ReceivePutAway.ExpireDateState>()
.NextTo<ReceivePutAway.ReceiveMode.ConfirmState>()
)
);
}
// PUT AWAY MODE
if (mode is ReceivePutAway.PutAwayMode putAwayMode)
{
putAwayMode.Intercept.CreateStates.ByAppend(
b => new[] { new AutoQtyState() }
);
putAwayMode.Intercept.CreateTransitions.ByReplace(basis =>
Base1.StateFlow(flow => flow
.From<ReceivePutAway.InventoryItemState>()
.NextTo<ReceivePutAway.LotSerialState>()
.NextTo<ReceivePutAway.LocationState>()
.NextTo<AutoQtyState>()
.NextTo<ReceivePutAway.PutAwayMode.ConfirmState>()
)
);
}
return mode;
}
}
}
Please let me know if additional details required.