Skip to main content
Solved

Trying to show a message on the Sales Order screen not tied to any specific field

  • Nov 23, 2026 4:13 PM UTC
  • 6 replies
  • 16 views
  • Translate All

Joe Schmucker
Captain II
Forum|alt.badge.img+3

I set a boolean to true if my condition is met in the RowPersisting handler on SOOrder.  It loops through the lines and finds if there is a row where discount amount = 0.

I do not want to prevent the record from being saved.  I just want a popup to display warning them there is a row with a zero discount.

In the SOOrder rowpersisted, I have a check to see if the warning is true.

		protected virtual void _(Events.RowPersisted<CRQuote> e)
{
var row = (CRQuote)e.Row;
if (row == null) return;

if (e.TranStatus == PXTranStatus.Completed)
{
if (showWarning)
{



}
}
}

I don’t can’t throw any exceptions or it will prevent the record from being saved.  I also cannot use a “.Ask” popup as it causes the event to fire again and causes an error that the record was already modified.

Also, I don’t want to display any messages in rowselected.  I just want this to be verified when they are saving the record.

I tried this because it says WithWarning, but it prevents saving the record.

throw new PXOperationCompletedWithWarningException(ICSMessages.MissingPriceOrDiscount, PXErrorLevel.Warning);

How can I just put a message box on the screen without throwing an exception? 

RaiseExceptionHandling does not show a dialog on the screen.

My last ditch effort might be to put a string field on the screen and hide it unless the warning condition exists, but that seems like a lot of churn to just show a message box.

This seems like it should be a no-brainer.

 

 

Best answer by darylbowman

Have you tried overriding the Persist method instead? That would be the place for it, I think. You could either execute the base Persist after the dialog if you want the dialog result to change whether or not it actually saves, or you could put it before (allowing it to save first) if it’s just informational.

Just make sure to check the graph’s flags so you don’t have dialogs popping up during mass-processing, etc:

private bool CanShowDialog() =>
!Base.UnattendedMode // graphs created in code
&& !Base.IsImport // import/export scenarios, contract-based and SOAP API
&& !Base.IsContractBasedAPI // set by the same check as IsImport; explicit for clarity
&& !Base.IsMobile // optional, see below
&& !PXLongOperation.IsLongOperationContext(); // processing, GI mass actions, long-running actions

 

View original

6 replies

Forum|alt.badge.img+8
  • Captain II
  • Nov 23, 2026 4:21 PM UTC

You can use something like:

PopupNoteManager.RegisterText(Base.Document.Cache, row, "OrderNbr", "Please enter the missing field data.");

But you should strongly consider adding a warning on the row. You can still stop the record from being saved but the yellow triangle that indicates the problem to the user before they’re told about the problem can go a long way to getting them to enter the data correctly the first time.

It also saves time for the user because they know what row to correct without having to search around.

Translate

darylbowman
Captain II
Forum|alt.badge.img+17

Have you tried overriding the Persist method instead? That would be the place for it, I think. You could either execute the base Persist after the dialog if you want the dialog result to change whether or not it actually saves, or you could put it before (allowing it to save first) if it’s just informational.

Just make sure to check the graph’s flags so you don’t have dialogs popping up during mass-processing, etc:

private bool CanShowDialog() =>
!Base.UnattendedMode // graphs created in code
&& !Base.IsImport // import/export scenarios, contract-based and SOAP API
&& !Base.IsContractBasedAPI // set by the same check as IsImport; explicit for clarity
&& !Base.IsMobile // optional, see below
&& !PXLongOperation.IsLongOperationContext(); // processing, GI mass actions, long-running actions

 

Translate

darylbowman
Captain II
Forum|alt.badge.img+17

You can use something like:

PopupNoteManager.RegisterText(Base.Document.Cache, row, "OrderNbr", "Please enter the missing field data.");

Just a note: this is no longer a dialog in Modern UI. It’s a 'toast’. If a dialog is a requirement, don’t use this.

 

Translate

Joe Schmucker
Captain II
Forum|alt.badge.img+3
  • Author
  • Captain II
  • Nov 23, 2026 4:31 PM UTC

​@darylbowman so would I use a view.ask popup after the persist is completed in the override?

Translate

darylbowman
Captain II
Forum|alt.badge.img+17

That’s what I’d try. Can’t say I have experience doing it (that I recall).

Translate

Joe Schmucker
Captain II
Forum|alt.badge.img+3
  • Author
  • Captain II
  • Nov 23, 2026 5:16 PM UTC

​@darylbowman Works!  The CanShowDialog will definitely save me a head scratcher later!!

Here is my final code in case anyone else needs to do this:

		public bool showWarning;

protected virtual void SOOrder_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
{
var row = (SOOrder)e.Row;
if (row == null) return;

PXCache lineCache = Base.Caches[typeof(SOLine)];
foreach (SOLine line in Base.Transactions.Select())
{
if (lineCache.GetStatus(line) != PXEntryStatus.Deleted)
{
if (line.CuryDiscAmt == null || line.CuryDiscAmt == 0)
{
showWarning = true;
}

if (line.CuryUnitPrice == null || line.CuryUnitPrice == 0)
{
showWarning = true;
}
}
}
}

public bool CanShowDialog() =>
!Base.UnattendedMode // graphs created in code
&& !Base.IsImport // import/export scenarios, contract-based and SOAP API
&& !Base.IsContractBasedAPI // set by the same check as IsImport; explicit for clarity
&& !Base.IsMobile // optional, see below
&& !PXLongOperation.IsLongOperationContext(); // processing, GI mass actions, long-running actions

/// Overrides <seealso cref="SOOrderEntry.Persist"/>
[PXOverride]
public void Persist(Action base_Persist)
{
base_Persist();

if (showWarning && CanShowDialog())
{
Base.Document.Ask(
"Warning",
ICSMessages.MissingPriceOrDiscount,
MessageButtons.OK,
MessageIcon.Warning);
}
}

protected virtual void _(Events.RowSelected<SOLine> e)
{
var row = (SOLine)e.Row;
if (row == null) return;

PXUIFieldAttribute.SetVisible<SOLine.discountID>(e.Cache, null, false);
KitInfo.SetEnabled(true);
InvAvail.SetEnabled(true);

if (row.CuryDiscAmt == null || row.CuryDiscAmt == 0)
{
e.Cache.RaiseExceptionHandling<SOLine.curyDiscAmt>(
row,
row.CuryDiscAmt,
new PXSetPropertyException<SOLine.curyDiscAmt>(ICSMessages.MissingPriceOrDiscount, PXErrorLevel.Warning)
);
}

if (row.CuryUnitPrice == null || row.CuryUnitPrice == 0)
{
e.Cache.RaiseExceptionHandling<SOLine.curyUnitPrice>(
row,
row.CuryUnitPrice,
new PXSetPropertyException<SOLine.curyUnitPrice>(ICSMessages.MissingPriceOrDiscount, PXErrorLevel.Warning)
);
}
}

 

Translate