Hi, I have a requirement where some validations are to occur once the inventory ID field is updated in the Requisitions screen. The logic is based on values taken from custom fields in a custom form and synced with user defined field in Summary area of requisition form and line item’s inventory ID. The logic is attached but the warning and error messages are not executed. Please let me know how to solve this issue.
protected virtual void RQRequisitionLine_InventoryID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler)
{
InvokeBaseHandler?.Invoke(cache, e);
RQRequisitionLine rowLine = (RQRequisitionLine)e.Row;
if (rowLine == null) return;
// Get current Requisition
RQRequisition row = Base.Document.Current;
// Find my custom field from Extension
var ext = PXCache<RQRequisition>.GetExtension<RQRequisitionExt>(row);
DateTime currentDate = DateTime.Today;
// Find record from VNPIProjectItem custom form view
foreach (VOPIProjectItem projectItemList in PXSelect<VOPIProjectItem>.Select(Base).FirstTableItems)
{
//loop through requisition line records
foreach (RQRequisitionLine lines in PXSelect<RQRequisitionLine, Where<RQRequisitionLine.reqNbr, Equal<Required<RQRequisition.reqNbr>>>>
.Select(Base, row.ReqNbr))
{
if (ext.UsrprojectSelectorCustom == "NONPROJECT")
{
string warningMsg = "Non-Project ID Selected";
throw new PXSetPropertyException(warningMsg, PXErrorLevel.Warning);
}
if ((!ext.UsrprojectSelectorCustom.Equals("NONPROJECT")) && (!projectItemList.ProjectID.Contains(ext.UsrprojectSelectorCustom.Trim())
&& lines.InventoryID != Convert.ToInt32(projectItemList.StockItemID.Trim())) &&
(currentDate >= projectItemList.StartDate && currentDate <= projectItemList.EndDate))
{
string errorMsg = "Project Item Budget does not Exist";
throw new PXSetPropertyException(errorMsg, PXErrorLevel.Error);
}
if (lines.OrderQty > projectItemList.BalanceQty)
{
string errorMsg = "Project Budget Quantity has been Exceeded";
throw new PXSetPropertyException(errorMsg, PXErrorLevel.Error);
}
}
}
}