Skip to main content
Answer

Make Premium Freight Field Mandatory on SO Value

  • October 15, 2025
  • 10 replies
  • 91 views

Hey Guys,

 

Whats a low code way to prevent save unless CuryPremiumFreightCost > 0 where an SO or QT order type CuryVatTaxableTotal >$5000.

 

Cheers,

Best answer by darylbowman

Try this:

protected virtual void _(Events.RowPersisting<SOOrder> e, PXRowPersisting b)
{
b?.Invoke(e.Cache, e.Args);

SOOrder row = e.Row;
if (row is null) return;

if (row.OrderType.IsIn(SOOrderTypeConstants.SalesOrder, SOOrderTypeConstants.QuoteOrder) &&
(row.CuryVatTaxableTotal ?? 0m) > 5000m &&
(row.CuryPremiumFreightAmt ?? 0m) == 0)
{
e.Cache.RaiseExceptionHandling<SOOrder.curyPremiumFreightAmt>(row, row.CuryPremiumFreightAmt,
new PXSetPropertyException(row, "Freight must be greater than 0.00", PXErrorLevel.Error));
}
}

 

10 replies

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

Do you mean CuryPremiumFreightAmt?


  • Author
  • Freshman I
  • October 21, 2025

yes.


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

Something like this:

using PX.Common;
using PX.Data;
using PX.Objects.SO;

namespace TEST
{
public class Test : PXGraphExtension<SOOrderEntry>
{
protected virtual void _(Events.FieldVerifying<SOOrder, SOOrder.curyPremiumFreightAmt> e, PXFieldVerifying b)
{
b?.Invoke(e.Cache, e.Args);

SOOrder row = e.Row;
if (row is null) return;

if (row.OrderType.IsIn(SOOrderTypeConstants.SalesOrder, SOOrderTypeConstants.QuoteOrder) &&
(row.CuryVatTaxableTotal ?? 0m) > 5000m &&
(row.CuryPremiumFreightAmt ?? 0m) == 0)
{
e.Cache.RaiseExceptionHandling<SOOrder.curyPremiumFreightAmt>(row, e.NewValue,
new PXSetPropertyException(row, "Freight must be greater than 0.00", PXErrorLevel.Error));
}
}
}
}

 


  • Author
  • Freshman I
  • October 22, 2025

Something like this:

using PX.Common;
using PX.Data;
using PX.Objects.SO;

namespace TEST
{
public class Test : PXGraphExtension<SOOrderEntry>
{
protected virtual void _(Events.FieldVerifying<SOOrder, SOOrder.curyPremiumFreightAmt> e, PXFieldVerifying b)
{
b?.Invoke(e.Cache, e.Args);

SOOrder row = e.Row;
if (row is null) return;

if (row.OrderType.IsIn(SOOrderTypeConstants.SalesOrder, SOOrderTypeConstants.QuoteOrder) &&
(row.CuryVatTaxableTotal ?? 0m) > 5000m &&
(row.CuryPremiumFreightAmt ?? 0m) == 0)
{
e.Cache.RaiseExceptionHandling<SOOrder.curyPremiumFreightAmt>(row, e.NewValue,
new PXSetPropertyException(row, "Freight must be greater than 0.00", PXErrorLevel.Error));
}
}
}
}

 

Thanks Daryl, where do I post this code in the customisations package? Sorry I'm still learning the customisation packages!


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

Under the CODE section, you can create a Graph Extension of PX.Objects.SO.SOOrderEntry. Then paste just this inside the existing code:

protected virtual void _(Events.FieldVerifying<SOOrder, SOOrder.curyPremiumFreightAmt> e, PXFieldVerifying b)

        {

            b?.Invoke(e.Cache, e.Args);

            SOOrder row = e.Row;

            if (row is null) return;

            if (row.OrderType.IsIn(SOOrderTypeConstants.SalesOrder, SOOrderTypeConstants.QuoteOrder) &&

                (row.CuryVatTaxableTotal ?? 0m) > 5000m &&

                (row.CuryPremiumFreightAmt ?? 0m) == 0)

            {

                e.Cache.RaiseExceptionHandling<SOOrder.curyPremiumFreightAmt>(row, e.NewValue, 

                    new PXSetPropertyException(row, "Freight must be greater than 0.00", PXErrorLevel.Error));

            }

        }

 

And add this to the very top (if you don't see it there already):

using PX.Common;

 


  • Author
  • Freshman I
  • October 23, 2025

Under the CODE section, you can create a Graph Extension of PX.Objects.SO.SOOrderEntry. Then paste just this inside the existing code:

protected virtual void _(Events.FieldVerifying<SOOrder, SOOrder.curyPremiumFreightAmt> e, PXFieldVerifying b)

        {

            b?.Invoke(e.Cache, e.Args);

            SOOrder row = e.Row;

            if (row is null) return;

            if (row.OrderType.IsIn(SOOrderTypeConstants.SalesOrder, SOOrderTypeConstants.QuoteOrder) &&

                (row.CuryVatTaxableTotal ?? 0m) > 5000m &&

                (row.CuryPremiumFreightAmt ?? 0m) == 0)

            {

                e.Cache.RaiseExceptionHandling<SOOrder.curyPremiumFreightAmt>(row, e.NewValue, 

                    new PXSetPropertyException(row, "Freight must be greater than 0.00", PXErrorLevel.Error));

            }

        }

 

And add this to the very top (if you don't see it there already):

using PX.Common;

 

Thanks Daryl,,

I'm getting the below error upon attempting to validate the project.

[2025-10-23 19:06:52.397] \App_Code\Caches\InvoiceDocumentsV3[2024.1].SOOrderEntry.cs(57): error CS0101: The namespace 'PX.Objects.SO' already contains a definition for 'SOOrderEntry_Extension' [2025-10-23 19:06:52.428] Compiler time, in seconds: 42.6371421 [2025-10-23 19:06:52.678] Validation failed.


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

You can change the code to say SOOrderEntryExt or something instead.


  • Author
  • Freshman I
  • October 23, 2025

Thanks! Published - but it doesn't seem to be doing anything. at what point is the error supposed to flag?


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

Nuts. I was thinking incorrectly and used the wrong event. I'll look at this again tomorrow.


darylbowman
Captain II
Forum|alt.badge.img+15
  • Answer
  • October 24, 2025

Try this:

protected virtual void _(Events.RowPersisting<SOOrder> e, PXRowPersisting b)
{
b?.Invoke(e.Cache, e.Args);

SOOrder row = e.Row;
if (row is null) return;

if (row.OrderType.IsIn(SOOrderTypeConstants.SalesOrder, SOOrderTypeConstants.QuoteOrder) &&
(row.CuryVatTaxableTotal ?? 0m) > 5000m &&
(row.CuryPremiumFreightAmt ?? 0m) == 0)
{
e.Cache.RaiseExceptionHandling<SOOrder.curyPremiumFreightAmt>(row, row.CuryPremiumFreightAmt,
new PXSetPropertyException(row, "Freight must be greater than 0.00", PXErrorLevel.Error));
}
}