Search code examples
acumatica

Acumatica Scan barcode


In Acumatica project , on Receipt screen have a lookup button "Add Item". When Inventory lookup show dialog ( it's FromDetail template ), i will scan barcode from my bill. But, i must scan second times it to working. How can i to filter grid details and set checked a row filtered according barcode ? And how can to know row count filtered? . Please help me.

The below figure illustrates.

snip code

Screen Receipt


Solution

  • You will be in a much better position with FieldVerifying handler implemented as follows for the INSiteStatusFilter.BarCode field to split scanned barcode and assign the new values both to BarCode field (though the PXFieldVerifyingEventArgs.New property) and custom unbound FilterQtySelected field. Then inside the FieldUpdated handler you will select all records from the detail grid, that satisfy filter condition and set Qty. Selected according to your unbound FilterQtySelected field:

    public class INReceiptEntryExt : PXGraphExtension<INReceiptEntry>
    {
        public class INSiteStatusFilterExt : PXCacheExtension<INSiteStatusFilter>
        {
            #region QtySelected
            public abstract class filterQtySelected : PX.Data.IBqlField
            {
            }
            [PXQuantity]
            public virtual decimal? FilterQtySelected { get; set; }
            #endregion
        }
    
        public void INSiteStatusFilter_BarCode_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            var barCode = (string)e.NewValue;
            string[] codes = barCode.Split(';');
            decimal qtySelected;
            if (codes.Length == 3 && decimal.TryParse(codes[2], out qtySelected))
            {
                e.NewValue = codes[1];
                sender.GetExtension<INSiteStatusFilterExt>(e.Row).FilterQtySelected = qtySelected;
                return;
            }
            sender.GetExtension<INSiteStatusFilterExt>(e.Row).FilterQtySelected = null;
        }
    
        public void INSiteStatusFilter_BarCode_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            INSiteStatusFilter filter = e.Row as INSiteStatusFilter;
            var filterExt = filter.GetExtension<INSiteStatusFilterExt>();
            if (string.IsNullOrEmpty(filter.BarCode) || !filterExt.FilterQtySelected.HasValue) return;
    
            foreach(INSiteStatusSelected record in Base.sitestatus.Select())
            {
                record.Selected = true;
                record.QtySelected = sender.GetExtension<INSiteStatusFilterExt>(e.Row).FilterQtySelected;
                Base.sitestatus.Update(record);
            }
        }
    }
    

    enter image description here