Hello everyone,
We have an inventory item with the tracking method set to “Track Serial Numbers”, which allows users to manually enter serial numbers.
We recently added a feature for some inventory items to auto-generate serial numbers from a numbering sequence on the Save action.
However, when trying to assign the generated serial number to the Lot/Serial Number field during Save, we encounter the following error:
“Key field cannot start with a leading space.”
We are confident that the serial number generated from the numbering sequence does not contain any spaces.
Could someone advise on the correct approach to assign auto-generated serial numbers to serial-tracked inventory items on Save without triggering this error?
Thank you in advance!
protected virtual void POReceiptLine_RowPersisting(PXCache sender, PXRowPersistingEventArgs e, PXRowPersisting BaseEvent)
{
BaseEvent.Invoke(sender, e);
var lineitem = (POReceiptLine)e.Row;
if (lineitem == null)
return;
if (Convert.ToString(e.Operation) == "Normal, Insert" || Convert.ToString(e.Operation) == "Normal, Update")
{
string serialNbr = AutoNumberAttribute.GetNextNumber(sender, lineitem, numSeq, Base.Accessinfo.BusinessDate);
Base.transactions.SetValueExt<POReceiptLine.lotSerialNbr>(lineitem, serialNbr);
}
}