Skip to main content

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?

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

}

 


Thank you!


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