RowSelected warning misses the first row.

I’m pulling my hair out a bit. I was helped along on this project by another user and I think I'm missing something here: 

I need each row to show a warning containing the various vendor prices. When I use the RowSelected event the top row value gets cleared out and when I change vendors it no longer updates the price. See images for expected behavior and current result.

(originally I was using RowUpdated (which worked) but then I would have to update the row before the warning would occur)

Any help would be greatly appreciated

using PX.Data;
using PX.Data.BQL;
using PX.Data.BQL.Fluent;
using PX.Objects.AP;
using PX.Objects.PO;
using System;
using System.Text;

namespace PX.Objects.SO
public class POCreate_ExtensionAI : PXGraphExtension<POCreate>
public static bool IsActive() => true;

#region Event Handlers

protected void _(Events.RowSelected<POFixedDemand> e)
var row = (POFixedDemand)e.Row;
if (row == null || row.InventoryID == null || row.OrderQty == null) return;
PXUIFieldAttribute.SetWarning<POFixedDemand.effPrice>(Base.FixedDemand.Cache, row, null);
string msg = GetQtyMessage(row.InventoryID, row.VendorID, row.OrderQty, null);
PXUIFieldAttribute.SetWarning<POFixedDemand.effPrice>(Base.FixedDemand.Cache, row, msg);

protected decimal GetItemQtyTotalOnPO(int? inventoryID)
decimal retVal = 0;

foreach (POFixedDemand line in Base.FixedDemand.Select())
if (line.InventoryID == inventoryID)
retVal += line.OrderQty ?? 0;
return retVal;

protected string GetQtyMessage(int? inventoryID, int? vendorID, decimal? lineQty, DateTime? requestedDate)
if (inventoryID == null || vendorID == null || lineQty == null) return null;

StringBuilder p = new StringBuilder();
decimal orderQty = GetItemQtyTotalOnPO(inventoryID);
if (requestedDate == null) requestedDate = Base.Accessinfo.BusinessDate;

var prices =
.View.ReadOnly.Select(Base, inventoryID, requestedDate, requestedDate);

var vendors =
.View.ReadOnly.Select(Base, inventoryID);

if (prices == null) return null;

p.AppendLine("Pricing available:");
foreach (APVendorPrice price in prices)

string vendorName = "empty";
foreach (Vendor vendor in vendors)
if (vendor.BAccountID == price.VendorID)
vendorName = vendor.AcctName.ToString();

p.AppendLine(vendorName + ":");

p.AppendLine($"You have {orderQty:n2} on this Purchase Order");
return p.ToString();



expected behavior:




0 replies

Be the first to 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