Skip to main content
Solved

Getting Scan and Count to save an updated custom field to other screens

  • January 14, 2025
  • 1 reply
  • 55 views

  • Freshman II
  • 8 replies

Hello again,

I have a custom field INPIDetailExt.usrAbsVarQty that gets populated correctly by both the PI Review and Scan and Count screens. However, a change to the field by Scan and Count does not reflect accurately on PI Review, even though Scan and Count changes the physical quantity on both forms.

When I put in the data for serial number ---78109 into Scan and Count, this is the result:

But later, on PI Review, the absolute variance quantity is still at 40:

 

I figure this has something to do with how PXCache works, but even after looking at a lot of documentation and searching the business logic code for how the other fields are updated/saved, I haven’t gotten any of my ideas to work. I am also suspecting incorrect inheritance/extension on my part. 

 

Here is my code for the various screens and sources I’ve tried:

Host

using System;
using System.Collections.Generic;
using PX.Common;
using PX.Data;
using PX.Data.BQL;
using PX.Data.BQL.Fluent;
using PX.BarcodeProcessing;
//using WMSBase = WarehouseManagementSystem<INScanCount, INScanCount.Host>;
using PX.Objects;
using PX.Objects.IN.WMS;

namespace PX.Objects.IN.WMS
{
  public class INScanCount_Host_Extension : PXGraphExtension<PX.Objects.IN.INPICountEntry>
  {
    #region Event Handlers

    protected void INPIDetail_PhysicalQty_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
    {
      var row = (INPIDetail)e.Row;
      if (row is null) return;

      decimal varianceQuantityVariable = (decimal)(row.PhysicalQty - row.BookQty);//how variance quantity is initially calculated

      decimal absoluteVarianceQuantity = Math.Abs(varianceQuantityVariable);

      cache.SetValueExt<INPIDetailExt.usrAbsVarQty>(row, absoluteVarianceQuantity);

      return;

    }
    #endregion
  }
}

-----------------------------------------

INPICountEntry (Physical Inventory Count)

using System;
using System.Collections;
using System.Collections.Generic;
using PX.Data;
using PX.Objects.CS;
using PX.Objects.GL;
using PX.Objects.IN.PhysicalInventory;
using PX.Objects.RQ;
using PX.Objects;
using PX.Objects.IN;

namespace PX.Objects.IN
{
  //this is for the Physical Inventory Count screen, where there are multiple individual input boxes at the top
  //INPICountEntry is what Scan and Count extends in the source code (Scan and Get inherits Methods and Views from INPICountEntry)
  public class INPICountEntry_Extension : PXGraphExtension<PX.Objects.IN.INPICountEntry>
  {

    #region Event Handlers
    protected void INPIDetail_PhysicalQty_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
    {
      INPIDetail detailRow = e.Row as INPIDetail;

      if (detailRow is null) return;

      INPIDetailExt inpiDetailExtVar = PXCache<INPIDetail>.GetExtension<INPIDetailExt>(detailRow);

      decimal varianceQuantityVariable = (decimal)(detailRow.PhysicalQty - detailRow.BookQty);//how variance quantity is initially calculated

      decimal absoluteVarianceQuantity = Math.Abs(varianceQuantityVariable);

      cache.SetValueExt<INPIDetailExt.usrAbsVarQty>(detailRow, absoluteVarianceQuantity);

      return;
    }
    #endregion

  }//end of Class
}//end of namespace

-----------------------------------------

INPIReview (Physical Inventory Review) this one already works as intended

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using PX.Common;
using PX.Data;
using PX.Data.BQL;
using PX.Data.BQL.Fluent;
using PX.Objects.CM;
using PX.Objects.Common.Extensions;
using PX.Objects.CS;
using PX.Objects.IN.PhysicalInventory;
using PX.Data.WorkflowAPI;
using PX.Objects;
using PX.Objects.IN;

namespace PX.Objects.IN
{
  //this is for the PI Review screen, where data can be entered manually line by line
  public class INPIReview_Extension : PXGraphExtension<PX.Objects.IN.INPIReview>
  {
    protected void INPIDetail_PhysicalQty_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
    {

      var row = (INPIDetail)e.Row;
      if (row == null) return;

      decimal varianceQuantityVariable = (decimal)(row.PhysicalQty - row.BookQty);//how variance quantity is initially calculated

      decimal absoluteVarianceQuantity = Math.Abs(varianceQuantityVariable);

      cache.SetValueExt<INPIDetailExt.usrAbsVarQty>(row, absoluteVarianceQuantity);

      return;

    }

  }
}

-----------------------------------------

INScanCount

using System;
using System.Collections.Generic;
using PX.Common;
using PX.Data;
using PX.Data.BQL;
using PX.Data.BQL.Fluent;
using PX.BarcodeProcessing;
//using WMSBase = WarehouseManagementSystem<INScanCount, INScanCount.Host>;
using PX.Objects;
using PX.Objects.IN.WMS;

namespace PX.Objects.IN.WMS
{
  //this is for the Scan and Count screen that the mobile scanners use, this is the most important one
  public class INScanCount_Extension : INScanCount.ScanExtension
  {
    #region Event Handlers
    protected void INPIDetail_PhysicalQty_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
    {
      INPIDetail detailRow = e.Row as INPIDetail;
      if (detailRow is null) return;

      INPIDetailExt inpiDetailExtVar = PXCache<INPIDetail>.GetExtension<INPIDetailExt>(detailRow);

      decimal varianceQuantityVariable = (decimal)(detailRow.PhysicalQty - detailRow.BookQty);//how variance quantity is initially calculated

      decimal absoluteVarianceQuantity = Math.Abs(varianceQuantityVariable);

      cache.SetValueExt<INPIDetailExt.usrAbsVarQty>(detailRow, absoluteVarianceQuantity);

      return;
    }
    #endregion
  }
}

 

Best answer by Natesan Sivarama

Hello ​@u662 ,

 

Here, “INPICountEntry” is the base for the “Scan and Count” WMS screen.

So, to update the “Absolute Variance Quantity” using the “Scan and Count” screen, you must extend the “INPICountEntry” graph and add PhysicalQty_FieldUpdated event as shown in the sample below:

 

  public class INPICountEntry_Extension : PXGraphExtension<PX.Objects.IN.INPICountEntry>
  {
     #region Event Handlers
    protected void INPIDetail_PhysicalQty_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
    {
      INPIDetail detailRow = e.Row as INPIDetail;

      if (detailRow is null) return;

      INPIEntry entry = PXGraph.CreateInstance<INPIEntry>();

      INPIDetailExt inpiDetailExtVar = PXCache<INPIDetail>.GetExtension<INPIDetailExt>(detailRow);

      decimal varianceQuantityVariable = (decimal)(detailRow.PhysicalQty - detailRow.BookQty);//how variance quantity is initially calculated

      decimal absoluteVarianceQuantity = Math.Abs(varianceQuantityVariable);

      cache.SetValueExt<INPIDetailExt.usrAbsVarQty>(detailRow, absoluteVarianceQuantity);

      entry.PIHeader.Current = Base.PIHeader.Current;
      entry.PIDetail.Update(detailRow);
      entry.Save.Press();

      return;
    }
    #endregion
  }

If you want to update the “Physical Qty” from the “PI Review (IN305000)” screen, add the INPIReview_Extension and include the PhysicalQty_FieldUpdated event.
There is no need to create graph extensions for INScanCount and Host.

 

 

View original
Did this topic help you find an answer to your question?

1 reply

  • Acumatica Moderator
  • 8 replies
  • Answer
  • January 21, 2025

Hello ​@u662 ,

 

Here, “INPICountEntry” is the base for the “Scan and Count” WMS screen.

So, to update the “Absolute Variance Quantity” using the “Scan and Count” screen, you must extend the “INPICountEntry” graph and add PhysicalQty_FieldUpdated event as shown in the sample below:

 

  public class INPICountEntry_Extension : PXGraphExtension<PX.Objects.IN.INPICountEntry>
  {
     #region Event Handlers
    protected void INPIDetail_PhysicalQty_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
    {
      INPIDetail detailRow = e.Row as INPIDetail;

      if (detailRow is null) return;

      INPIEntry entry = PXGraph.CreateInstance<INPIEntry>();

      INPIDetailExt inpiDetailExtVar = PXCache<INPIDetail>.GetExtension<INPIDetailExt>(detailRow);

      decimal varianceQuantityVariable = (decimal)(detailRow.PhysicalQty - detailRow.BookQty);//how variance quantity is initially calculated

      decimal absoluteVarianceQuantity = Math.Abs(varianceQuantityVariable);

      cache.SetValueExt<INPIDetailExt.usrAbsVarQty>(detailRow, absoluteVarianceQuantity);

      entry.PIHeader.Current = Base.PIHeader.Current;
      entry.PIDetail.Update(detailRow);
      entry.Save.Press();

      return;
    }
    #endregion
  }

If you want to update the “Physical Qty” from the “PI Review (IN305000)” screen, add the INPIReview_Extension and include the PhysicalQty_FieldUpdated event.
There is no need to create graph extensions for INScanCount and Host.

 

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings