Skip to main content
Solved

FieldVerifying or FieldUpdating?


Forum|alt.badge.img+5

In the Sales Order screen, I want to take an Inventory ID value that the user has entered, say, “APPLE”. I want to look for that value in another table and possibly replace the value of APPLE with some other value.

I have tried changing e.NewValue in a FieldVerifying event.

A very simple version of my code is here and AMCOTTON is an existing inventory item. So, in testing this I hoped that it would but AMCOTTON into that field regardless of what I entered.

protected void SOLine_InventoryID_FieldVerifying(PXCache cache, PXFieldVerifyingEventArgs e, PXFieldVerifying InvokeBaseHandler)
    {

      e.NewValue = "AMCOTTON";
      if (InvokeBaseHandler != null)
        InvokeBaseHandler(cache, e);


    }

However, I end up with a blank field value.

Is FieldVerifying the right event to make changes to e.NewValue?

Best answer by Django

In the end I used FieldUpdating this allowed me to access the value that the user had entered in e.NewValue and then I was able to change it as required before running the base handler.

Interesting note that this method was invoked event before the Base.Document.Current had been instantiated. That I found puzzling but it was easy to handle.

protected void SOLine_InventoryID_FieldUpdating(PXCache cache, PXFieldUpdatingEventArgs e, PXFieldUpdating InvokeBaseHandler)
{

  Boolean runMyLogic = false;

  if (Base.Document.Current == null) return;

  //check a bunch of things to determine if I need to run my logic

  if (runMyLogic)
  {
    e.NewValue = locateADifferentInventoryID(e.NewValue);
  }

  if (InvokeBaseHandler != null)
    InvokeBaseHandler(cache, e);

}

 

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

3 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3381 replies
  • March 20, 2022

Hi @ddunn  FieldVerifying event is only used to verify the values OR compare values.

For your requirement, the right event would be FieldUpdated event.  

 

protected void SOLine_InventoryID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler)
    {

      if (InvokeBaseHandler != null)
        InvokeBaseHandler(cache, e);
 if (row != null)
            {

// Fetch and compare value from another table

                row.InventoryID = 1234;
            }

    }

 


Forum|alt.badge.img+5
  • Author
  • Captain II
  • 503 replies
  • March 20, 2022

Thank you!


Forum|alt.badge.img+5
  • Author
  • Captain II
  • 503 replies
  • Answer
  • March 21, 2022

In the end I used FieldUpdating this allowed me to access the value that the user had entered in e.NewValue and then I was able to change it as required before running the base handler.

Interesting note that this method was invoked event before the Base.Document.Current had been instantiated. That I found puzzling but it was easy to handle.

protected void SOLine_InventoryID_FieldUpdating(PXCache cache, PXFieldUpdatingEventArgs e, PXFieldUpdating InvokeBaseHandler)
{

  Boolean runMyLogic = false;

  if (Base.Document.Current == null) return;

  //check a bunch of things to determine if I need to run my logic

  if (runMyLogic)
  {
    e.NewValue = locateADifferentInventoryID(e.NewValue);
  }

  if (InvokeBaseHandler != null)
    InvokeBaseHandler(cache, e);

}

 


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