Hello colleagues,
I am implementing event handler for StockItem to force User must enter value for selector Weight UOM. The field Weight UOM doesn’t have red red icon on the left of label
using the following code:
protected void InventoryItem_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
{
var row = (InventoryItem)e.Row;
if (row == null) return;
if (e.Operation == PXDBOperation.Insert)
{
if (string.IsNullOrEmpty(row.WeightUOM))
{
var fieldDisplayName = PXUIFieldAttribute.GetDisplayName<InventoryItem.weightUOM>(cache);
var localizedErrorMessage = PXMessages.LocalizeFormat("Field {0} can't be empty", fieldDisplayName);
PXUIFieldAttribute.SetError<InventoryItem.weightUOM>(cache, row, null);
cache.RaiseExceptionHandling<InventoryItem.weightUOM>(e.Row, row.WeightUOM, new PXSetPropertyException(localizedErrorMessage, PXErrorLevel.Error));
}
}
}
I used the same code for field Weight (type: decimal?) and it works fine
Do you have any idea?