'Creating a Adjustment before Processing a (pick,pack,ship) scan
I am trying to create an Adjustment to my stock as I am scanning the item.
The code works and the adjustment is released as expected. The problem is the data is not submitted to SQL before the base method is invoked. Is there a way to force the data to be pushed to SQL before the base method is called?
I have tried adding a PXTransactionScope but after the ts.complete the data on SQL has not been updated
[PXOverride]
public virtual void ProcessLotSerialBarcode(string barcode, ProcessLotSerialBarcodeDelegate baseMethod)
{
string LotnumberWithOutPrf =// code to extract Lotnumber from QR code
//check if lot has stock
INItemLotSerial iNItemLotSerial = PXSelect<
INItemLotSerial,
Where<INItemLotSerial.lotSerialNbr, Equal<Required<INItemLotSerial.lotSerialNbr>>,
And<INItemLotSerial.inventoryID, Equal<Required<INItemLotSerial.inventoryID>>>>>
.Select(Base, Lotnumber, Base.HeaderView.Current.InventoryID);
//if there is no stock do adjustment
if (iNItemLotSerial.QtyHardAvail == 0)
{
using (PXTransactionScope ts = new PXTransactionScope())
{
INAdjustmentEntry iNAdjustmentEntryEntry = PXGraph.CreateInstance<INAdjustmentEntry>();
INRegister iNRegister = new INRegister();
iNRegister.ExtRefNbr = "N/A";
iNRegister.TranDesc = "Adjustment for Shipment: " + Base.HeaderView.Current.RefNbr;
iNRegister.Hold = false;
iNAdjustmentEntryEntry.adjustment.Insert(iNRegister);
INTran iNTran = iNAdjustmentEntryEntry.transactions.Insert();
iNTran.InventoryID = Base.HeaderView.Current.InventoryID;
iNTran.SiteID = 9;
iNTran.LocationID = 77;
iNTran.Qty = 1;
iNTran.UOM = Base.HeaderView.Current.UOM;
iNAdjustmentEntryEntry.transactions.Update(iNTran);
iNTran.LotSerialNbr = LotnumberWithOutPrf;
iNAdjustmentEntryEntry.transactions.Update(iNTran);
iNAdjustmentEntryEntry.Save.PressButton();
iNAdjustmentEntryEntry.release.Press();
iNAdjustmentEntryEntry.Save.PressButton();
iNAdjustmentEntryEntry.Cancel.PressButton();
ts.Complete(Base);
}
}
baseMethod?.Invoke(LotnumberWithOutPrf);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
