Search code examples
acumatica

Acumatica calling ApplyState method in Scan and Receive screen


Good day

I am trying to call the ApplyState(state) function. This is a protected function inside PX.Objects.IN.INScanReceive.

I am reading a QR code and the value has a lot/serial number and expiry date. The idea is to set the 2 values during the ProcessItemBarcode function call. The problem is when calling the base method the state is set and the "screens state" wants me to scan the lot/serial.

What I need to do is call the ProcessConfirm() or ApplyState(state). But calling the functions inside ProcessItemBarcode is where I stuck:

using PX.Common;
using PX.Data;
using WMSBase = PX.Objects.IN.WarehouseManagementSystemGraph<PX.Objects.IN.INScanReceive, PX.Objects.IN.INScanReceiveHost, PX.Objects.IN.INRegister, PX.Objects.IN.INScanReceive.Header>;
using PX.Objects.IN;

namespace MyCustomPackage.Graph.Extension
{
    public class INScanReceiveHostExtCustomPackage2 : PXGraphExtension<INScanReceive, INScanReceiveHost>
    {
        public static bool IsActive() => true;

        #region Overrides ProcessItemBarcode
        //ProcessItemBarcode
        public delegate void ProcessItemBarcodeDelegate(string barcode);

        [PXOverride]
        public virtual void ProcessItemBarcode(string barcode, ProcessItemBarcodeDelegate baseMethod)
        {
            //..//logic go change barcode 
            baseMethod?.Invoke(barcode);

            // Option one call ApplyState()
            Base.ApplyState()
            // Option2 one call ProcessLotSerialBarcode 
            // I dont know how to send the delegate
            ProcessLotSerialBarcode(barcode, );
        }
        #endregion

        #region Overrides ProcessLotSerialBarcode
        //ProcessLotSerialBarcode
        public delegate void ProcessLotSerialBarcodeDelegate(string barcode);

        [PXOverride]
        public virtual void ProcessLotSerialBarcode(string barcode, ProcessLotSerialBarcodeDelegate baseMethod)
        {
            baseMethod?.Invoke(barcode);
        }
        #endregion

        [PXProtectedAccess]
        public abstract class INScanReceiveHostExtProtectedAccess : PXGraphExtension<INScanReceiveHostExtCustomPackage, INScanReceive, INScanReceiveHost>
        {
            [PXProtectedAccess(typeof(INScanReceive))]
            protected abstract void ProcessItemBarcode(string barcode);

            [PXProtectedAccess(typeof(INScanReceive))]
            protected abstract void ApplyState(string state);

            [PXProtectedAccess(typeof(INScanReceive))]
            protected abstract void ProcessLotSerialBarcode(string barcode);
        }
    }
}


Solution

  • This is not the preferred method but when I can't figure out another option I will copy the source from Acumatica, e.g. Static methods and private ones. I will make note in my code that they were copied so I can make sure to duplication the process when versions change. You can then call those methods locally. Not elegant but works for me :)