Solved

FieldVerifying or FieldUpdating?

  • 19 March 2022
  • 3 replies
  • 533 views

Userlevel 7
Badge +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?

icon

Best answer by Django 21 March 2022, 03:42

View original

3 replies

Userlevel 7
Badge +17

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;
}

}

 

Userlevel 7
Badge +5

Thank you!

Userlevel 7
Badge +5

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


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved