Skip to main content
Question

“inventoryid cannot be found” error over riding “inventoryid does not exist ” when field is made required

  • March 18, 2025
  • 1 reply
  • 11 views

Forum|alt.badge.img

I set the inventoryid to required on the inventory screen. I want to still get the error message of “inventoryid cannot be found” if someone does fill in the incorrect inventory id.
So basically if the inventory id is blank I should get this error: “inventory id is required.

If inventory id is entered but does not exist in the system: “Iventoryid does not exist”

 

Before making the inventoryid required, the “Iventoryid does not exist” error came through when trying to save. Now it is overiiden by the “inventoryid cannot be found”. I don't want this to happen

PS I used PXDefault attribute to make the field required

1 reply

Forum|alt.badge.img+8
  • Captain II
  • 366 replies
  • March 18, 2025

@LungileNjakazi37 

 

Not sure if there is a low/no code way to set two different errors like that.

You could set it in the RowUpdated event handler something like:

protected virtual void _(Events.RowUpdated<InventoryItem> e, PXRowUpdated b)
{
b?.Invoke(e.Cache, e.Args);

InventoryItem row = e.Row;
if(row == null) return;

if(row.InventoryID /*Could be InventoryCD*/ == null)
{
throw new PXSetPropertyException<InventoryItem.inventoryID/*Could be InventoryCD*/>("YourErrorMessage", PXErrorLevel.Error);
}
}

If the InventoryID is not valid, the system should default to the other error message.

 

Hope this helps

Aleks


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